Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Visual Basic (https://www.askmehelpdesk.com/forumdisplay.php?f=469)
-   -   Please, help me to edit my code (https://www.askmehelpdesk.com/showthread.php?t=598231)

  • Sep 21, 2011, 07:24 AM
    Y_Nessi
    Please, help me to edit my code
    Option Explicit
    Dim lbl1, lbl2, lbl3
    Private Sub cmdStart_Click()
    Static I, ii, iii, win
    Static f As Integer
    Dim rd As Integer
    Static Pos As Integer
    If cmdStart.Caption = "Start" Then
    cmdStart.Caption = "Stop"
    Randomize
    Do
    rd = Int(Rnd * 10)
    lblDigit.Caption = rd
    lblDigit.Refresh
    DoEvents
    If f = 1 Then
    f = 0
    Exit Do
    End If
    Loop While True
    Else
    f = 1
    cmdStart.Caption = "Start"
    If Pos = 0 Then
    cmdStart.Left = txtPII.Left
    txtPI.Text = lblDigit.Caption
    I = txtPI.Text
    Pos = 1
    ElseIf Pos = 1 Then
    cmdStart.Left = txtPIII.Left
    txtPII.Text = lblDigit.Caption
    ii = txtPII.Text
    Pos = 2
    Else
    cmdStart.Left = txtPI.Left
    txtPIII.Text = lblDigit.Caption
    iii = txtPIII.Text
    lbl1 = lblplayerI
    lbl2 = lblplayerII
    lbl3 = lblplayerIII
    If I > ii Then
    If I > iii Then
    win = I
    MsgBox " The winner is " & lbl1 & " = " & win, vbInformation, "Information"
    ElseIf I < iii Then
    win = iii
    MsgBox " The winner is " & lbl3 & " = " & win, vbInformation, "Information"
    Else
    win = I
    MsgBox " The winner is " & lbl1 & " and " & lbl3 & " = " & win & " are the winners" & vbInformation, "Information"
    End If
    ElseIf I < ii Then
    If ii > iii Then
    win = ii
    MsgBox " The winner is " & lbl2 & " = " & win, vbInformation, "Information"
    ElseIf ii < iii Then
    win = iii
    MsgBox " The winner is " & lbl3 & " = " & win, vbInformation, "Information"
    Else
    win = ii
    MsgBox " The winner is " & lbl2 & " and " & lbl3 & " = " & win & " are the winners" & vbInformation, "Information"
    End If
    ElseIf I = ii Then
    If I > iii Then
    win = I
    MsgBox " The winner is " & lbl1 & " = " & win, vbInformation, "Information"
    ElseIf I < iii Then
    win = iii
    MsgBox " The winner is " & lbl3 & " = " & win, vbInformation, "Information"
    Else
    win = I
    MsgBox " The winner is " & lbl1 & lbl2 & "," & " and " & lbl3 & " = " & win & " are the winners " & vbInformation, "Information"
    End If
    End If
    Pos = 0
    End If
    End If
    End Sub
  • Sep 21, 2011, 07:31 AM
    Curlyben
    It would help if you could explain what you are trying to achieve here.
  • Sep 21, 2011, 07:41 AM
    Y_Nessi
    It will be error if I run and result for 2 numbers are equal.

  • All times are GMT -7. The time now is 09:40 PM.