always says -1 for low score because...
It always displays -1 for the low number because it is the loop flag to stop the input boxes how can I stop that? :confused: here is the code:
Code:
Private strTempScore As String, lnghigh As Long, lnglow As Long, intscore As Integer
Const strTitle As String = "Bowling scores"
Const strPrompt As String = "Enter a score (-1 to finish):"
Const strSentinel As String = -1 'Loop flag
Private Sub cmddone_Click()
End
End Sub
Private Sub cmdscores_Click()
strTempScore = InputBox(strPrompt, strTitle) 'Get Score
If strTempScore = "" Then
intscore = strSentinel
Else
intscore = strTempScore
End If
lnghigh = intscore
lnglow = intscore
Do While intscore <> strSentinel
strTempScore = InputBox(strPrompt, strTitle)
If strTempScore = "" Then
intscore = strSentinel
Else
intscore = strTempScore
' Check if the score is higher than the highest score so far
lnghigh = IIf(intscore > lnghigh, intscore, lnghigh)
' Check if the score is lower that the lowest score so far
lnglow = IIf(intscore < lnglow, intscore, lnglow)
End If
Loop
End Sub
Private Sub cmdstats_Click()
lblhigh.Caption = lnghigh
lbllow.Caption = lnglow
End Sub
Private Sub Form_Load()
lblhigh.Caption = ""
lbllow.Caption = ""
End Sub