VB自动说话代码 可以帮我解释下这个代码么

来源:百度知道 编辑:UC知道 时间:2024/05/31 15:39:35
Dim i%
Private Sub Command1_Click()
If Text1.Text = "" Then
Call MsgBox("TEXT内容不能为空!", vbExclamation, "提示")
Else
i = i + 1
If i Mod 2 = 0 Then
Timer1.Enabled = False: Command1.Caption = "开始"
Else
Timer1.Enabled = True: Command1.Caption = "停止"
End If
End If
End Sub

Private Sub Form_Load()
Me.Caption = "SendKeys": Command1.Caption = "开始": Text1 = "" _
: Timer1.Interval = 1000: Timer1.Enabled = False
End Sub

Private Sub Text1_Change()
If Len(Text1) > 1 Then Text1 = Left$(Text1, 1)
End Sub

Private Sub Timer1_Timer()
SendKeys "{" & Text1 & "}"
End Sub

Dim i% '声明变量i
Private Sub Command1_Click() '估计是开始按钮
If Text1.Text = "" Then '如果为空
Call MsgBox("TEXT内容不能为空!", vbExclamation, "提示") '提示
Else '否则
i = i + 1 'i增加1
If i Mod 2 = 0 Then '如果i是2的倍数
Timer1.Enabled = False: Command1.Caption = "开始" '标题改为开始,关闭计时器
Else
Timer1.Enabled = True: Command1.Caption = "停止" '标题改为停止,启动计时器
End If
End If
End Sub

Private Sub Form_Load() '窗体加载时
Me.Caption = "SendKeys": Command1.Caption = "开始": Text1 = "" _
: Timer1.Interval = 1000: Timer1.Enabled = False '计时器每秒运行一次
End Sub

Private Sub Text1_Change()
If Len(Text1) > 1 Then Text1 = Left$(Text1, 1) '改变时只留下第一个字符
End Sub

Private Sub Timer1_Timer()
SendKeys "{" &