求一简单的VB程序代码拜托各位大神

求一简单的VB程序代码拜托各位大神,第1张

'添加两个TextBox框 分别穗枣设猜弯拆置其MultiLine=True ScrollBars=2 示例代码如下: Private Sub Form_Click() Dim a(1 To 60) As Integer Randomize Timer Print "原数组是:" For i = 1 To 60 a(i) = Int(Rnd * 101 + 100) Print a(i)" "If i Mod 10 = 0 Then Print Next i Print Print "排序后的数组是:" For i = 1 To 59 For j = i + 1 To 60 If a(i) <a(j) Then c = a(i) a(i) = a(j) a(j) = c End If Next j Next i For i = 1 To 60 Print a(i)" "If i Mod 10 = 0 Then Print Next i Print For i = 1 To 60 If a(i) Mod 2 <>0 Then js = js &a(i) &" " Else os = a(i) &" "闹或 &os End If Next i js = Trim(js) os = Trim(os) js1 = Split(js, " ") os1 = Split(os, " ") For i = 0 To UBound(js1) Text1.Text = Text1.Text &js1(i) &" " b = b + 1 If b Mod 10 = 0 Then Text1.Text = Text1.Text &vbCrLf Next i For i = 0 To UBound(os1) Text2.Text = Text2.Text &os1(i) &" " c = c + 1 If c Mod 10 = 0 Then Text2.Text = Text2.Text &vbCrLf Next i 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

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

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


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

原文地址: http://outofmemory.cn/yw/12475951.html

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

发表评论

登录后才能评论

评论列表(0条)

保存