Reputation: 11
I have the following code behind a userform
Private Sub add_button()
On Error Resume Next
If TextBox1 > TextBox9 Then
TextBox12 = "YES"
Else
TextBox12 = "No"
If TextBox8 > TextBox3 And TextBox8 < TextBox4 Then
TextBox11 = "YES"
Else
TextBox11 = "no"
If TextBox12 = "NO" Then
TextBox10 = "NO"
ElseIf TextBox11 = "NO" Then
TextBox10 = "NO"
Else
TextBox10 = "YES"
End If
End If
End If
End Sub
The above code does not work: please advice on possible errors.
Upvotes: 0
Views: 2218
Reputation: 35557
Please can you check that the actual conditions of the script are working as I'm a little unsure how well these conditions will work against text. Just copy out all the existing code and copy the following in as a test:
Private Sub add_button()
If TextBox1 > TextBox9 Then
MsgBox "TextBox1 > TextBox9 "
Else
MsgBox "TextBox1 < TextBox9 "
If TextBox8 > TextBox3 And TextBox8 < TextBox4 Then
MsgBox "TextBox8 > TextBox3 And TextBox8 < TextBox4 "
End
End If
End Sub
Upvotes: 0
Reputation: 14361
Few things,
Textbox.Text
F8
and adding break points
Debug.Print
or a Msgbox
at each if-else
to ensure the logic flowHere is change you could do to your code. At this point of the logic you have already set both 12
and 11
to NO
in that case it is unnecessary to do this check:
If TextBox12 = "NO" Then
TextBox10 = "NO"
ElseIf TextBox11 = "NO" Then
TextBox10 = "NO"
You may simply set Textbox10.Text = "NO"
Upvotes: 1