vb简单程序代码

vb简单程序代码,第1张

我做的,你看看,自己修改修改吧,附件传不上,就贴代码吧,控件就几个

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

'万花筒程序

'粘贴下面代码即可, 不用添加任何控件

Private WithEvents Timer1 As Timer

Dim r&, r1&, t&, a1!, a2!, xb!, yb!, s!, b#

Private Sub Form_Load()

      Me.Width = 4500: Me.Height = 4500

      Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2

      Me.AutoRedraw = True

      Me.Caption = "CBM666的万花筒"

      Set Timer1 = Controls.Add("vb.timer", "Timer1")

      Timer1.Interval = 10

End Sub

Private Sub Timer1_Timer()

      Randomize

      r = 340 * Rnd

      If r <> 0 Then

         r1 = 500

         s = r * Rnd

         b = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)

         For t = 1 To 10000

            a1 = t * 3.1415926 / 180

            a2 = (r1 / r) * a1

            xb 局桐= 500 + (-(r1 - r) * Cos(a1) - s * Cos(a2 - a1) + 420) * 4

            卖腊谨yb = 500 + ((r1 - r) * Sin(a1) - s * Sin(a2 - a1) + 380) * 4

            Me.PSet (xb, yb), 中基b

         Next t

      End If

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12508706.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存