简易三国志
创建9个command,1个timer,时间20000,9个text,6个farm。
布置如图
代码如下
Private Sub Form_Load()
Text1.Text = "100" '我方剩余士兵
Text2.Text = "170" '对方剩余士兵
Text3.Text = "180" '对方剩余士兵
Text4.Text = "200" '对方剩余士兵
Text5.Text = "500" '金钱
Text6.Text = "170" '武将血量
Text7.Text = "120" '武将血量
Text8.Text = "150" '武将血量
Text9.Text = "151" '武将血量
End Sub
Private Sub command1_click()
If Text1.Text < "0" Or Text6.Text < "0" Then
MsgBox "无法攻击!"
Else:
Do
Text1.Text = Text1.Text - 5
Text2.Text = Text2.Text - 10
Text6.Text = Text6.Text - 10 '你的攻击力暂定为200
Text7.Text = Text7.Text - 5 '你的攻击力暂定为200
Loop Until Text2.Text = "0" Or Text7.Text = "0"
MsgBox "本轮进攻胜利!"
Text5.Text = Text5.Text + 500
End If
End Sub
Private Sub command2_click()
If Text1.Text < "0" Or Text6.Text < "0" Then
MsgBox "无法攻击!"
Else:
Do
Text1.Text = Text1.Text - 10
Text3.Text = Text3.Text - 10
Text6.Text = Text6.Text - 10 '你的攻击力暂定为200
Text8.Text = Text8.Text - 10
Loop Until Text3.Text = "0" Or Text7.Text = "0"
MsgBox "本轮进攻胜利!"
Text5.Text = Text5.Text + 300
End If
End Sub
Private Sub command3_click()
If Text1.Text < "0" Or Text6.Text < "0" Then
MsgBox "无法攻击!"
Else:
Do
Text1.Text = Text1.Text - 20
Text4.Text = Text4.Text - 10
Text6.Text = Text6.Text - 10 '你的攻击力暂定为200
Text9.Text = Text9.Text - 10
Loop Until Text4.Text = "0" Or Text7.Text = "0"
MsgBox "本轮进攻胜利!"
Text5.Text = Text5.Text + 700
End If
End Sub
Private Sub command4_click()
Text1.Text = Text1.Text + 100
Text5.Text = Text5.Text - 50
If Text5.Text = "0" Then
MsgBox "没钱了!"
If Text1.Text = "0" Then
MsgBox "没兵了!"
End If
End If
End Sub
Private Sub command5_click()
Text6.Text = Text1.Text + 300
Text5.Text = Text5.Text - 100
If Text5.Text = "0" Then
MsgBox "没钱了!"
If Text6.Text = "0" Then
MsgBox "没血了!"
End If
End If
End Sub
Private Sub command6_click()
Text6.Text = Text1.Text + 1000
Text5.Text = Text5.Text - 500
If Text5.Text = "0" Then
MsgBox "没钱了!"
If Text6.Text = "0" Then
MsgBox "没可买的了!"
End If
End If
End Sub
Private Sub command7_click()
MsgBox "城市名;洛阳 黄金500 兵马170 守城大将张飞!"
End Sub
Private Sub command8_click()
MsgBox "城市名;长安 黄金400 兵马180 守城大将孙权!"
End Sub
Private Sub command9_click()
MsgBox "城市名;合肥 黄金700 兵马200 守城大将姜维!"
End Sub
Private SubIf Timer1 = "0" Then
MsgBox "台风来啦!"
Text1.Text = Text1.Text - 100
Text5.Text = Text5.Text - 100
End Sub