vb简单程序代码
答案:2 悬赏:0 手机版
解决时间 2021-03-22 13:35
- 提问者网友:爱唱彩虹
- 2021-03-21 16:47
vb简单程序代码
最佳答案
- 五星知识达人网友:拜訪者
- 2021-03-21 17:29
我做的,你看看,自己修改修改吧,附件传不上,就贴代码吧,控件就几个
2个command,2个label,1个text,1个timer。直接放就行
Dim sj As Integer, jia As Integer, bjia As Integer, total As Integer
Private Sub Command1_Click()
Call chou
Timer1.Enabled = True
Command2.Top = Command1.Top
Command2.Left = Command1.Left
Command1.Visible = False
Command2.Visible = True
End Sub
Private Sub Command2_Click()
If Val(Text1) = jia + bjia Then
total = total + 10
Else
total = total - 10
End If
Label2.Caption = "总分:" + Str(total)
Call chou
Text1 = ""
If total < 0 Then
MsgBox "分数低于0,GameOver!", vbExclamation, "游戏"
Timer1.Enabled = False
Command1.Visible = True
Command2.Visible = False
total = 0
Exit Sub
ElseIf total = 100 Then
MsgBox "分数满100分,游戏结束!", vbExclamation, "游戏"
Timer1.Enabled = False
total = 0
Exit Sub
End If
sj = 10
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
Me.Caption = "小游戏"
Command1.Caption = "开始"
Command2.Caption = "确定"
Command2.Visible = False
Text1 = ""
Label2.Caption = "总分:?"
Label1.Caption = "?+?"
sj = 10
End Sub
Sub chou()
Randomize
jia = Int(Rnd(1) * 89 + 10)
bjia = Int(Rnd(1) * 89 + 10)
Label1.Caption = Str(jia) + "+" + CStr(bjia) + "= ?"
Text1.SetFocus
End Sub
Private Sub Timer1_Timer()
If sj = 0 Then
total = total - 10
sj = 10
Call chou
End If
Me.Caption = "小游戏 " + Str(sj) + "秒"
sj = sj - 1
End Sub
2个command,2个label,1个text,1个timer。直接放就行
Dim sj As Integer, jia As Integer, bjia As Integer, total As Integer
Private Sub Command1_Click()
Call chou
Timer1.Enabled = True
Command2.Top = Command1.Top
Command2.Left = Command1.Left
Command1.Visible = False
Command2.Visible = True
End Sub
Private Sub Command2_Click()
If Val(Text1) = jia + bjia Then
total = total + 10
Else
total = total - 10
End If
Label2.Caption = "总分:" + Str(total)
Call chou
Text1 = ""
If total < 0 Then
MsgBox "分数低于0,GameOver!", vbExclamation, "游戏"
Timer1.Enabled = False
Command1.Visible = True
Command2.Visible = False
total = 0
Exit Sub
ElseIf total = 100 Then
MsgBox "分数满100分,游戏结束!", vbExclamation, "游戏"
Timer1.Enabled = False
total = 0
Exit Sub
End If
sj = 10
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
Me.Caption = "小游戏"
Command1.Caption = "开始"
Command2.Caption = "确定"
Command2.Visible = False
Text1 = ""
Label2.Caption = "总分:?"
Label1.Caption = "?+?"
sj = 10
End Sub
Sub chou()
Randomize
jia = Int(Rnd(1) * 89 + 10)
bjia = Int(Rnd(1) * 89 + 10)
Label1.Caption = Str(jia) + "+" + CStr(bjia) + "= ?"
Text1.SetFocus
End Sub
Private Sub Timer1_Timer()
If sj = 0 Then
total = total - 10
sj = 10
Call chou
End If
Me.Caption = "小游戏 " + Str(sj) + "秒"
sj = sj - 1
End Sub
全部回答
- 1楼网友:痴妹与他
- 2021-03-21 17:38
细节自己修改
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯