Hello folks! I am trying to learn VBA and found a book to help me. I am using some code it gave me for an example of StrComp:
Private Sub cmdCompare_Click()
Dim iResult As Integer
iResult = StrComp(txtFirst.Value, txtSecond.Value)
Select Case iResult
Case -1
MsgBox "The first string is less than the second"
Case 0
MsgBox "Both strings are equal"
Case 1
MsgBox "The first string is greater than the second"
Case Else
MsgBox "One or both of the strings are Null"
End Select
End Sub
The debugger states that the line:
iResult = StrComp(txtFirst.Value, txtSecond.Value)
is the culprit, each time I leave one of the text boxes empty. The companion software with the same code that I downloaded for the book does the same thing.
The book is for access 2007 and I have 2010, so I do not know if something changed or if it is just bad code, but I would like to know what is generating the error.
I appreciate the help!