Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement with two conditions

Status
Not open for further replies.

sf123

Programmer
Oct 9, 2002
30
US
I have a syntax error that I am sure is a simple error but I can't seem to figure it out:

If (x >= infoFrom And x<= infoTo) Then
counter=counter+1
End If

Any ideas?
Thanks!
 
Try
If ((x >= infoFrom) And (x<= infoTo)) Then
counter=counter+1
End If


A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
I tried that and it doesn't work. I tried it again by taking out the second half of the if statement and the counter worked fine. So I know that the problem must be the syntax of my AND in the if statement.
 
Hi sf123,

I ran your code in my VB 6 environment... I dont get
a syntax error.

Dim x As String
Dim infoFrom As String
Dim infoTo As String
Dim iCtr As Integer


If (x >= infoFrom And x <= infoTo) Then
iCtr = iCtr + 1
End If


Can you compare your code to mine and give us the exact error message ?
John
 
I figured it out.
Somewhere much earlier in my program I was using that variable in a different statement and made it equal to another number.. really brilliant..
- Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top