It should work if you change all your Or's to Ands(i.e If Val(Text10.Text) <= 100 And Val(Text10.Text) >= 97 Then).
Altenatively you might find this quite a bit simpler:
Dim Score As Integer
Score = Val(Text10.Text)
If Score <= 100 Then
If Score >= 97 Then
Text11.Text = 1
ElseIf Score >= 91 Then
Text11.Text = 1.25
ElseIf Score >= 85 Then
Text11.Text = 1.5
ElseIf Score >= 79 Then
Text11.Text = 1.75
ElseIf Score >= 73 Then
Text11.Text = 2
ElseIf Score >= 67 Then
Text11.Text = 2.25
ElseIf Score >= 61 Then
Text11.Text = 2.5
ElseIf Score >= 55 Then
Text11.Text = 2.75
ElseIf Score >= 50 Then
Text11.Text = 3
ElseIf Score >= 25 Then
Text11.Text = 4
Else
Text11.Text = 5
End If
End If
You also could use a Select-Case block:
If Score <= 100 Then
Select Case Score
Case Score >= 97
Text11.Text = 1
Case Score >= 91
Text11.Text = 1.25
End Select
End If
tinstaafl
Nearly a Posting Virtuoso
1,328 posts since Jun 2010
Reputation Points: 355
Solved Threads: 231
Skill Endorsements: 14
Question Answered as of 2 Months Ago by
tinstaafl Use the Change event(double-click on the textbox to create the code stub to handle the Change event). Then something like this in the sub routine:
Dim Value as Integer
Value = Val(Text2.Text)
If Value > 100 Or Value < 0 Then
Text2.Text = ""
Msgbox "Value must be between 0 and 100 inclusive"
End If
tinstaafl
Nearly a Posting Virtuoso
1,328 posts since Jun 2010
Reputation Points: 355
Solved Threads: 231
Skill Endorsements: 14