If then else query...

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I insert a number into textbox1 between the number of 1
and 37 and i need to manipulate what the user puts in.
For instance if they put between 1 and 5 they get a
certain price and between 6 and 10 annother price and so
on.. I tried coding...

If textbox1 = 1 to 5
then msgbox("£16.00")
else
if textbox1 = 6 to 11
then msgbox("£25.00")

etc...

Please note I did that off the top of my head at work and
can anybody advise me the best way to do this in vb.net..
 
I would probably try something like this:

If me.textbox1.text <6 Then
msgbox("something")
else
if me.textbox1.text < 11Then
msgbox(something else)
else
if .... so on and so forth
end if
end if

Hope that helps.
 
OK the coding generally helps but you see the values are
in between values...

1-5 days = £16.00
6-11 days = £25.00
12-16 days = £32.00

and so on and so forth up to 38 days.

So i need an expression that says if textbox1 = between 1
and 5 then show whatever

and

if textbox1 = between 6 and 11 then show whatever ...

and so on up to 38days...

cheers
 
select case int.parse(textbox.text)
case 1 to 5
do something here
case 6 to 10
do something here
case else
handle anything else here
end select
 
Take one from the number of days, divide (integer arithmetic) by 5.
Then you have a simple case statement:
case 0:
MessageBox( "16" );
case 1:
... "25"

and so on. If you have an expression to calculate the amount from the number
of days, that's great, otherwise you could have a lookup that returns the
price. Then you only need one MessageBox statement and a function to give
you the price from the ( numberOfDays - 1 ) / 5.

Steve

OK the coding generally helps but you see the values are
in between values...

1-5 days = £16.00
6-11 days = £25.00
12-16 days = £32.00

and so on and so forth up to 38 days.

So i need an expression that says if textbox1 = between 1
and 5 then show whatever

and

if textbox1 = between 6 and 11 then show whatever ...

and so on up to 38days...

cheers
 
Back
Top