I will firstly apologise for the messy code.......
I am working from a userform, and have the textboxes, here named f1b2 and f1b3, I am wanting to cancel the exit from f1b2 if the number entered in the box is smaller than the number in f1b3 however in the following example the number in f1b2 is 12 and f1b3 is 6, thefore f1b2n < f1b3n should be false, however it appears to be returning a true value - can anyone assist?
Private Sub f1b2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim f1b3n, f1b2n, f1b1n As Long
Dim answer, answer2 As Integer
If IsNumeric(f1b3.Value) = True Then
f1b3n = f1b3.Value
Else
f1b3n = 1000
End If
If IsNumeric(f1b2.Value) = True Then
f1b2n = f1b2.Value
Else
f1b2n = 1000
End If
If f1b2.Value <> "" Then
If f1b1.Value = "" Then GoTo LASTONEf1b2
If f1b2n < f1b3n Then 'this line is where i am failing - f1b2n is 12 and f1b3n is 6 however it appears to be returning true as the msgbox pops up every time.....
answer2 = MsgBox("Lower", vbQuestion + vbYesNo + vbDefaultButton2, "Higher")
If answer2 = vbNo Then
Cancel = True
Exit Sub
End If
End If
End If
LASTONEf1b2:
If f1b2.Value = "" Then f1b2.Value = "None"
End Sub
I hope it's not just me being stupid somewhere..........
I am working from a userform, and have the textboxes, here named f1b2 and f1b3, I am wanting to cancel the exit from f1b2 if the number entered in the box is smaller than the number in f1b3 however in the following example the number in f1b2 is 12 and f1b3 is 6, thefore f1b2n < f1b3n should be false, however it appears to be returning a true value - can anyone assist?
Private Sub f1b2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim f1b3n, f1b2n, f1b1n As Long
Dim answer, answer2 As Integer
If IsNumeric(f1b3.Value) = True Then
f1b3n = f1b3.Value
Else
f1b3n = 1000
End If
If IsNumeric(f1b2.Value) = True Then
f1b2n = f1b2.Value
Else
f1b2n = 1000
End If
If f1b2.Value <> "" Then
If f1b1.Value = "" Then GoTo LASTONEf1b2
If f1b2n < f1b3n Then 'this line is where i am failing - f1b2n is 12 and f1b3n is 6 however it appears to be returning true as the msgbox pops up every time.....
answer2 = MsgBox("Lower", vbQuestion + vbYesNo + vbDefaultButton2, "Higher")
If answer2 = vbNo Then
Cancel = True
Exit Sub
End If
End If
End If
LASTONEf1b2:
If f1b2.Value = "" Then f1b2.Value = "None"
End Sub
I hope it's not just me being stupid somewhere..........