Помогите, пожалуйста! Нужно сделать, чтобы игру начинал компьютор, а не игрок
» Показать/скрыть спойлер... «
Код
Dim Number As Integer
Dim ngamer As Integer
Dim ncomp As Integer
Dim SumGamer As Integer
Dim SumComp As Integer
Dim Разность As Integer
Dim Resultgamer As Integer
Dim Resultcomp As Integer
Private Sub CommandButton1_Click()
CommandButton1.Enabled = False
CommandButton3.Enabled = False
Randomize
Number = Int(6 * Rnd) + 1
ngamer = 1
TextBox1.Text = CStr(ngamer)
SumGamer = Number
TextBox2.Text = CStr(SumGamer)
Randomize
Number = Int(6 * Rnd) + 1
ngamer = ngamer + 1
TextBox1.Text = CStr(ngamer)
SumGamer = SumGamer + Number
TextBox2.Text = CStr(SumGamer)
If SumGamer <= 12 Then
MsgBox "Продолжить игру? Да или нет"
OptionButton1.Enabled = True
OptionButton2.Enabled = True
End If
End Sub
Private Sub CommandButton2_Click()
Randomize
Number = Int(6 * Rnd) + 1
ngamer = ngamer + 1
TextBox1.Text = CStr(ngamer)
SumGamer = SumGamer + Number
TextBox2.Text = CStr(SumGamer)
If SumGamer > 12 Then
MsgBox "Компьютер выиграл"
TextBox3.Text = "Конец игры"
TextBox6.Text = "Конец игры"
Resultgamer = Resultgamer
Resultcomp = Resultcomp + 1
TextBox7.Text = CStr(Resultgamer)
TextBox8.Text = CStr(Resultcomp)
CommandButton3.Enabled = True
Else
MsgBox "Продолжить игру? Да или нет"
OptionButton1.Enabled = True
OptionButton2.Enabled = True
End If
End Sub
Private Sub CommandButton3_Click()
TextBox1.Text = 0
TextBox2.Text = 0
TextBox4.Text = 0
TextBox5.Text = 0
CommandButton1.Enabled = True
CommandButton2.Enabled = False
OptionButton1.Enabled = False
OptionButton2.Enabled = False
OptionButton1 = False
OptionButton2 = False
End Sub
Private Sub OptionButton1_Click()
CommandButton2.Enabled = True
CommandButton3.Enabled = False
End Sub
Private Sub OptionButton2_Click()
OptionButton1.Enabled = False
OptionButton2.Enabled = False
CommandButton2.Enabled = False
TextBox3.Text = "Ожидание"
TextBox6.Text = "Бросок"
Randomize
Number = Int(6 * Rnd) + 1
ncomp = 1
TextBox5.Text = CStr(ncomp)
SumComp = Number
TextBox4.Text = CStr(SumComp)
Randomize
Number = Int(6 * Rnd) + 1
ncomp = ncomp + 1
TextBox5.Text = CStr(ncomp)
SumComp = SumComp + Number
TextBox4.Text = CStr(SumComp)
If SumComp <= 6 Then
Randomize
Number = Int(6 * Rnd) + 1
ncomp = ncomp + 1
TextBox5.Text = CStr(ncomp)
SumComp = SumComp + Number
TextBox4.Text = CStr(SumComp)
End If
If SumComp < SumGamer Then
Randomize
Number = Int(6 * Rnd) + 1
ncomp = ncomp + 1
TextBox5.Text = CStr(ncomp)
SumComp = SumComp + Number
TextBox4.Text = CStr(SumComp)
End If
If SumComp > 12 Then
MsgBox "Игрок выиграл"
TextBox3.Text = "Конец партии"
TextBox6.Text = "Конец партии"
Resultgamer = Resultgamer + 1
Resultcomp = Resultcomp
TextBox7.Text = CStr(Resultgamer)
TextBox8.Text = CStr(Resultcomp)
CommandButton3.Enabled = True
End If
If SumComp = SumGamer Then
MsgBox "Ничья"
TextBox3.Text = "Конец партии"
TextBox6.Text = "Конец партии"
Resultgamer = Resultgamer + 1
Resultcomp = Resultcomp + 1
TextBox7.Text = CStr(Resultgamer)
TextBox8.Text = CStr(Resultcomp)
CommandButton3.Enabled = True
End If
If SumComp > SumGamer Then
MsgBox "Компьютер выиграл"
TextBox3.Text = "Конец партии"
TextBox6.Text = "Конец партии"
Resultgamer = Resultgamer
Resultcomp = Resultcomp + 1
TextBox7.Text = CStr(Resultgamer)
TextBox8.Text = CStr(Resultcomp)
CommandButton3.Enabled = True
End If
If SumComp < SumGamer Then
MsgBox "Игрок выиграл"
TextBox3.Text = "Конец партии"
TextBox6.Text = "Конец партии"
Resultgamer = Resultgamer + 1
Resultcomp = Resultcomp
TextBox7.Text = CStr(Resultgamer)
TextBox8.Text = CStr(Resultcomp)
CommandButton3.Enabled = True
End If
'количество партий
If Resultcomp + Resultgamer = 10 Then
MsgBox "Конец игры"
CommandButton1.Enabled = False
CommandButton2.Enabled = False
CommandButton3.Enabled = False
OptionButton1.Enabled = False
OptionButton2.Enabled = False
End If
End Sub
Private Sub UserForm_Initialize()
TextBox1.Text = 0
TextBox2.Text = 0
TextBox4.Text = 0
TextBox5.Text = 0
TextBox7.Text = 0
TextBox8.Text = 0
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False
TextBox8.Enabled = False
TextBox3.Text = "Бросок"
TextBox6.Text = "Ожидание"
CommandButton2.Enabled = False
OptionButton1.Enabled = False
OptionButton2.Enabled = False
End Sub
Сообщение отредактировано gormih - 25.05.2008 - 23:26