vb.net - Visual basic membership program using select case? -


I am writing a program that asks the user for their age and the number of years that they are members, I Trying to do this by using the selection case, though it does not seem to work, all ages are okay but if I want to use the checkbox to say that he is an elderly and should get a discount That's not working. Also, in the years in which they are members, their price / category does not change, my program is simple and I am not sure why this is not working.

The program's screen shot:

Code:

  Public class form 1 personal sub btnCalc_Click (System.Object, System by System Avent ARG) by BTNCL X = wal (txtAge.Text) select y = val (txtYears.Text) Case x is the case & lt; = 18lblPrice.Text = ("£ 60") lblCategory.Text = ("Junior") Episode 19 to 49lblPrice. Text = ("£ 120") lblCategory.Text = ("senior") episode> gt; = 50 lblPrice.Text = ("£ 80") lblCategory.Text = ("more than 50") case chkVeteran. Checked LblPrice.Text = ("£ 50") case is & lt; = 18 and y> gt = 2 lblPrice.Text = ("£ 40") lblCategory.Text = ("2-year junior discount") is the case & gt; = 50 and y> gt = 10 lblPrice.Text = ("£ 90") lblCategory.Text = ("10 year senior discount") case chkVeteran.Checked and y> gt = 10lblPrice.Text = ("£ 20" ) Lblcategory.Text = ("10 years      

Only one case can block blocks, but you are expecting many blocks to run. Consider this subtitle of your sections:

  is the case & Lt; = 18lblprice.Text = ("£ 60") lblCategory.Text = ("junior") case chkVeteran. Checked is lblPrice.Text = ("one pound 50") case & lt; = 18 and y> gt = 2 lblPrice.Text = ("£ 40") lblCategory.Text = ("2-year-olds R / discount ")   

If x is less than or equal to 18 then first case The block will go away. Regardless of the status of chkVeteran or y , others will not be taken care of. Case A series of must be mutually exclusive. For example:

  is the case & lt; = 18 and y  gt = 2 lblPrice.Text = ("£ 40") lblCategory.Text = ("2-year Junior Discount")   

These two sections are unique, therefore, Can apply only at one time. Each section will be examined from the beginning to the end and will have to run with the first match. Therefore you should set your logic that the first section that matches only section that matches.


Edit: In response to a different comment thread ...

You have defined the logic:

There are three categories of membership fees in a sports club, junior (18 years old) pays £ 60 per year, senior (19-49) £ 120 and veterans (50 and over) pay 80 pounds Junior who has been a member for 2 years or more, gets £ 20 less Senior and Veteran, who are members for 10 years or more There are, £ 30 less.

This would seem like two conditional scenes, first defining a base rate, something like this:

  If the age and lieutenant; 19 then rate = 60 and if age and lt; 50 Then Rate = 120 Other Rate = 80 End If   

The second will define the rebate for a base rate, something like this:

  If Age & LT; 19th & duration & gt; 1 then rate = rate - 20 and if age & gt; 18 more term & gt; 9 Then Rate = Rate - 30 End If two different conditional sequence, each checking  Absolutely  conditions is clearly defined in the requirements. After this, you can reserve them again and to make the meaning more clear. For example, extract definitions of "junior, senior and senior" in different arguments:  
  If IsJunior (age) then rate = 60 otherwise if IsSenior (age) then rate = 120 others Iveteran (age) then rate = 80 end if you can create a function for each of them, such as:  
  function IsJunior (ByVal age as integer) as the age of boolean returns & Lt; The 19 expiration function   

The details of the implementation of this small collaborative task are concluded and allows high level logic to be expressed in the meaning concept rather than the details of implementation The overall expression of the argument is allowed to match the details given by the requirements more clearly.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -