Log in

View Full Version : Please, help me to edit my code


Y_Nessi
Sep 21, 2011, 07:24 AM
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

Curlyben
Sep 21, 2011, 07:31 AM
It would help if you could explain what you are trying to achieve here.

Y_Nessi
Sep 21, 2011, 07:41 AM
It will be error if I run and result for 2 numbers are equal.