Followers 0

# [VB] Greater than or equal to and Less than and equal to if statements

## 2 posts in this topic

Hey there,

trying to create a simple application which can calculate quotes based on the size of a variable, but having a bit of trouble as I havnt touched Visual Basic in over 5 years.

So far I have this

        If width >= 1801 And <= 2000 Then
price = 1458
End If


is the width is equal to or larger than 1801 and the width is greater than or equal to 2000 then the price is 1458, although this is saying that the 2nd operator is infact an XML element?

Does anyone have an example of a working if statement like this that I can get an idea of?

Cheers

0

##### Share on other sites

Notice how when you said the sentence in English you used "width" twice. You most likely (I don't know anything about Visual Basic) need to do the same thing in code and say width <= 2000'. Computers are notoriously bad at figuring out things from context.

1

##### Share on other sites

That makes sense, I am also lead to believe I can't use 'width' as it's a system variable

        If theWidth >= 1801 And theWidth <= 2000 Then
price = 1458
End If
`

This seems to be working fine now, cheers

0

## Create an account

Register a new account