vb代码问题 急~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

来源:百度知道 编辑:UC知道 时间:2024/05/25 11:39:42
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Dim a As String
Dim b As String
Dim c, x, y As Integer
a = Text1.Text
b = Text2.Text
If IsNumeric(b) <> True Then
MsgBox "[倒计时]:输入的不是数字.请输入数字", 48, "错误"
Text2.Text = ""
Else
c = Abs(b)
y = c
AppActivate ("与 " & a & " " & "交谈中")
Do Until x > c
SendKeys (y)
SendKeys ("{Enter}")
x = x + 1
y = y - 1
Loop
End If
End Sub

为什么输入数字之后点击按钮 它只发送第一个数字?其余的数字都只留在输入框中???????????????????????????????????????????????????????????????

改为:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Dim a As String
Dim b As String
Dim c, x, y As Integer
a = Text1.Text
b = Text2.Text
If IsNumeric(b) <> True Then
MsgBox "[倒计时]:输入的不是数字.请输入数字", 48, "错误"
Text2.Text = ""
Else
c = Abs(b)
y = c
AppActivate ("与 " & a & " " & "交谈中")
Do Until x > c
DoEvents
Sleep 200
SendKeys y
SendKeys "{Enter}",True
x = x + 1
y = y - 1
Loop
End If
End Sub