IF, then, Else Functions errors
This may seem like a stupid question but I can't seem to get the IF function to work. I got it to work in an earlier section:
Code:
If txtSat1.Text = "" Then
If txtSat2.Text = "" Then
If cbSat.CheckState = 0 Then
MessageBox.Show("Please Enter Hours for Saturday")
End If
End If
End If
but with my current code here:
Code:
If txtSun1.Text <> Then
cbSun.CheckState = 0
Else If txtSun2.Text <> Then
cbSun.CheckState = 0
End If
Both the "Then"s are underline blue and it says "expression expected." I have two textboxes and a checkbox. If the user types something into either one of the textboxes, then I want the checkbox to not be able to be clicked. Any help would be appreciated.
Re: IF, then, Else Functions errors
Quote:
Originally Posted by
jhaag4
This may seem like a stupid question but I can't seem to get the IF function to work. I got it to work in an earlier section:
but with my current code here:
Code:
If txtSun1.Text <> Then
cbSun.CheckState = 0
Else If txtSun2.Text <> Then
cbSun.CheckState = 0
End If
If txtSun1.Text <> (not equal to what?) Then
Re: IF, then, Else Functions errors
OH. I thought that <> meant that the textbox.Text has something written in it by the user. Like the opposite of ""
Re: IF, then, Else Functions errors
There is no opposite of ""!
<> means literally 'either less than or greater than' and so 'does not equal'. In this case I imagine that what you want is
If txtSun1.Text <> "" Then
Re: IF, then, Else Functions errors
The <> is just a nice way of saying both < or >. In other words, not equal to. C-style languages often have a != operator which may make a bit more sense if you know that the ! is the not operator (or at least one of them), so it reads as Not Equal. However, the <> convention is much more common as far as I can tell, as it seems to extend beyond programming.
Re: IF, then, Else Functions errors
That was it! Thank you everyone!