Hello I am learning Visual Basic.net and am building simple windows applications out of a book. I am very new to this but until now have figured everything out. i have hacked at this for hours now to no avail, there might be some weird variables here and there when I was trying to improvise.
errMessage is a text string variable that changes based on which fields are invalid
'this way finds errors in my text fields but pops an empty error box even if the data is valid: (the debugger verifies these boolean values are all true)
If Not test1Result Or test2Result Or test3Result Or idIsValid Then
MessageBox.Show(errMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
'This way will not give an error at all, even if data is invalid but the values all return true
If (test1Result Or test2Result Or test3Result Or idIsValid) = False Then
MessageBox.Show(errMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
I attached the whole source code as well
Can anyone tell me what I'm doing wrong? How can the messagebox.show command exectute if the If returns False?
Thanks for your help
Be sure you know the priority of the operators. For example,
Not True or True or False or False =True
and Not (True or True or False or False)= False
So Not is considered sooner than Or.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979