用VB编写一个小程序

用VB编写一个小程序,第1张

Dim a, b

Private Sub Command1_Click()

End

End Sub

Private Sub Form_Load()

Text.Text = "Visual Basic程序设计"唯仔冲

Command1.Caption = "指歼结束"

Text.Left = 0: Text.Top = 0: Text.Width = 0.5 * Form1.Width

Text.Height = 0.5 * Form1.Height

a = Form1.Width - Command1.Left

b = Form1.Height - Command1.Top

End Sub

Private Sub Form_Resize()

Text.Left = 0: Text.Top = 0: Text.Width = 0.5 * Form1.Width

Text.Height = 0.5 * Form1.Height

Command1.Left = Form1.Width - a

Command1.Top = Form1.Height - b

End Sub

注意,各变戚神量名,控件名保持一致,你题目中的文本框名称为text

Private Sub Command1_Click()

  Me.Cls

  Dim N As Integer, i As Integer

  N = InputBox("n=", , 袭李9)

  For i = 1 To 2 * N - 1

    If i <= N Then

      Print Space(N - i) + String(2 * i - 1, CStr(i))

    Else

      Print Space(N - (2 行禅裂* N - i)) + String(2 * (2 * N - i) - 1, CStr(2 * N 档闭- i))

    End If

  Next i

End Sub

Dim sec, min, h

Private Sub Command1_Click()

Timer1.Enabled = True

h = Text1.Text

min = Text2.Text

sec = Text3.Text

Timer2.Enabled = False

End Sub

Private Sub Command2_Click()

End

End Sub

Private Sub Form_Load()

Form1.BackColor = &HFFFF00

Timer1.Enabled = False

Timer1.Interval = 1000

Timer2.Enabled = True

Timer2.Interval = 1000

Text1.Text = 2

Text2.Text = "00"

Text3.Text = "00"轮握

Command2.Caption = "腊册庆退出"

Command1.Caption = "开始倒计时"姿罩

End Sub

Private Sub Timer1_Timer()

If sec >0 Then

sec = sec - 1

Else:

If (min >0 Or h >0) Then

sec = 59

End If

If min >0 Then

min = min - 1

Else:

If h >0 Then

min = 59

End If

If h >0 Then

h = h - 1

Else: Timer1.Enabled = False

CreateObject("SAPI.SpVoice").Speak "GAME OVER!"

Form1.BackColor = &HFF

End If

End If

End If

Text1.Text = h

Text2.Text = min

Text3.Text = sec

Label6.Caption = Now

End Sub

Private Sub Timer2_Timer()

Label6.Caption = Now

End Sub


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存