using the if statement to place runners time in the correct space

please email adamlinkjr@msn.com
How do I use the if statement to place the times in the correct order?


Private Sub cmdCalculateResults_Click()
'This procedure calculates the race time of the three
'runners and displays it in the 1st place 2nd place 3rd place
Dim txtName1 As String
Dim txtName2 As String
Dim txtName3 As String
Dim sngRunner1 As Single
Dim sngRunner2 As Single
Dim sngRunner3 As Single



'Get the times entered by the user
sngRunner1 = Val(txtTime1.Text)
sngRunner2 = Val(txtTime2.Text)
sngRunner3 = Val(txtTime3.Text)


'Compare time results
If sngRunner1 > sngRunner2 Then
lblResult1.Caption = sngRunner2
End If
If sngRunner2 < sngRunner1 Then
lblResult1.Caption = sngRunner2
End If


















End Sub

Private Sub cmdClear_Click()
'This procedure clears the application
txtName1.Text = ""
txtName2.Text = ""
txtName3.Text = ""
txtTime1.Text = ""
txtTime2.Text = ""
txtTime3.Text = ""
lblResult1.Caption = ""
lblResult2.Caption = ""
lblResult3.Caption = ""
End Sub

Private Sub cmdClose_Click()
End
'This procedure ends the appliction
End Sub

Comments

  • : How do I use the if statement to place the times in the correct order?

    [code]
    'Compare time results
    If sngRunner1 > sngRunner2 Then
    If sngRunner3 > sngRunner1 Then
    lblResult1.Caption = sngRunner2
    lblResult2.Caption = sngRunner1
    lblResult3.Caption = sngRunner3
    ElseIf sngRunner3 > sngRunner2 Then
    lblResult1.Caption = sngRunner2
    lblResult2.Caption = sngRunner3
    lblResult1.Caption = sngRunner1
    Else
    lblResult1.Caption = sngRunner3
    lblResult2.Caption = sngRunner2
    lblResult1.Caption = sngRunner1
    End If
    Else
    If sngRunner3 > sngRunner2 Then
    lblResult1.Caption = sngRunner1
    lblResult2.Caption = sngRunner2
    lblResult3.Caption = sngRunner3
    ElseIf sngRunner3 > sngRunner1 Then
    lblResult1.Caption = sngRunner1
    lblResult2.Caption = sngRunner3
    lblResult1.Caption = sngRunner2
    Else
    lblResult1.Caption = sngRunner3
    lblResult2.Caption = sngRunner1
    lblResult1.Caption = sngRunner2
    End If
    End If
    [/code]
    Mike
  • : : How do I use the if statement to place the times in the correct order?
    :
    : [code]
    : 'Compare time results
    : If sngRunner1 > sngRunner2 Then
    : If sngRunner3 > sngRunner1 Then
    : lblResult1.Caption = sngRunner2
    : lblResult2.Caption = sngRunner1
    : lblResult3.Caption = sngRunner3
    : ElseIf sngRunner3 > sngRunner2 Then
    : lblResult1.Caption = sngRunner2
    : lblResult2.Caption = sngRunner3
    : lblResult1.Caption = sngRunner1
    : Else
    : lblResult1.Caption = sngRunner3
    : lblResult2.Caption = sngRunner2
    : lblResult1.Caption = sngRunner1
    : End If
    : Else
    : If sngRunner3 > sngRunner2 Then
    : lblResult1.Caption = sngRunner1
    : lblResult2.Caption = sngRunner2
    : lblResult3.Caption = sngRunner3
    : ElseIf sngRunner3 > sngRunner1 Then
    : lblResult1.Caption = sngRunner1
    : lblResult2.Caption = sngRunner3
    : lblResult1.Caption = sngRunner2
    : Else
    : lblResult1.Caption = sngRunner3
    : lblResult2.Caption = sngRunner1
    : lblResult1.Caption = sngRunner2
    : End If
    : End If
    : [/code]
    : Mike
    :

  • : : : How do I use the if statement to place the times in the correct
    Thanks Mike

    order?
    : :
    : : [code]
    : : 'Compare time results
    : : If sngRunner1 > sngRunner2 Then
    : : If sngRunner3 > sngRunner1 Then
    : : lblResult1.Caption = sngRunner2
    : : lblResult2.Caption = sngRunner1
    : : lblResult3.Caption = sngRunner3
    : : ElseIf sngRunner3 > sngRunner2 Then
    : : lblResult1.Caption = sngRunner2
    : : lblResult2.Caption = sngRunner3
    : : lblResult1.Caption = sngRunner1
    : : Else
    : : lblResult1.Caption = sngRunner3
    : : lblResult2.Caption = sngRunner2
    : : lblResult1.Caption = sngRunner1
    : : End If
    : : Else
    : : If sngRunner3 > sngRunner2 Then
    : : lblResult1.Caption = sngRunner1
    : : lblResult2.Caption = sngRunner2
    : : lblResult3.Caption = sngRunner3
    : : ElseIf sngRunner3 > sngRunner1 Then
    : : lblResult1.Caption = sngRunner1
    : : lblResult2.Caption = sngRunner3
    : : lblResult1.Caption = sngRunner2
    : : Else
    : : lblResult1.Caption = sngRunner3
    : : lblResult2.Caption = sngRunner1
    : : lblResult1.Caption = sngRunner2
    : : End If
    : : End If
    : : [/code]
    : : Mike
    : :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories