text文本框属性,在线等待
在VB窗体中,有三个文体框(text1,text2,text3),我想当text1输入完成文本3秒钟后text2才能输入文本,text2输完文本3秒钟后text3才能输入文体,请问代码如何写? --------------------编程问答-------------------- 用Sleep函数 或者 用timer控件 --------------------编程问答-------------------- 用一个timer控件控制--------------------编程问答-------------------- 在模块中声明
Public key As Integer
Private Sub Form_Load()
Text1.Enabled = True
Text2.Enabled = False
Text3.Enabled = False
End Sub
Private Sub Text1_Change()
Timer1.Enabled = False
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
key = KeyCode
Timer1.Enabled = True
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
key = KeyCode
Timer1.Enabled = True
End Sub
Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
key = KeyCode
Timer1.Enabled = True
End Sub
Private Sub Text2_Change()
Timer1.Enabled = False
End Sub
Private Sub Text3_Change()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If Text1.Enabled Then
If key = 13 Or key = 9 Then
Text2.Enabled = True
Text2.SetFocus
Text1.Enabled = False
Text3.Enabled = False
Timer1.Enabled = False
End If
ElseIf Text2.Enabled Then
If key = 13 Or key = 9 Then
Text3.Enabled = True
Text3.SetFocus
Text1.Enabled = False
Text2.Enabled = False
Timer1.Enabled = False
End If
ElseIf Text3.Enabled Then
If key = 13 Or key = 9 Then
Text1.Enabled = True
Text1.SetFocus
Text2.Enabled = False
Text3.Enabled = False
Timer1.Enabled = False
End If
End If
End Sub
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
先设置text2和text2不可用
在text1的keydown事件写
if keycode=vbKeyReturn then
sleep 3000
text2.enabled=true
end if
对text2也和text1一样写如上代码 --------------------编程问答-------------------- 用timer控件,时间间隔设置为3秒 --------------------编程问答--------------------
Private Sub Form_Load()
Timer1.Enabled = False
Text2.Locked = True
Text3.Locked = True
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If vbconde = vbEnter Then
Timer1.Enabled = True
Timer1.Interval = 9000
End If
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If vbconde = vbEnter Then
Timer1.Enabled = True
Timer1.Interval = 9000
End If
End Sub
Private Sub Timer1_Timer()
If Text2.Locked = True And Text3.Locked = True Then
Text2.Locked = False
Timer1.Enabled = False
Timer1.Interval = 9000
Else: Text3.Locked = False
End If
Timer1.Enabled = False
Timer1.Interval = 9000
End Sub
--------------------编程问答-------------------- 方法很简单,个人建议用TIME控件实现 --------------------编程问答--------------------
--------------------编程问答-------------------- 用sleep Api函数
'3个文本框,1个timer。。输入完数据按回车,3秒后下一个text可操作,并将焦点移动到此
Private Sub Form_Load()
Text1.Enabled = True
Text2.Enabled = False
Text3.Enabled = False
Timer1.Interval = 3000
Timer1.Enabled = False
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Text1.Text <> "" Then
If KeyAscii = 13 Then
Timer1.Enabled = True
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Text2.Text <> "" Then
If KeyAscii = 13 Then
Timer1.Enabled = True
End If
End If
End Sub
Private Sub Timer1_Timer()
If Text1.Text <> "" Then
Text2.Enabled = True
Text2.SetFocus
Timer1.Enabled = False
End If
If Text2.Text <> "" Then
Text3.Enabled = True
Text3.SetFocus
End If
End Sub
doevents
sleep 3
--------------------编程问答-------------------- 在Validate()事件里用Doevents:Sleep3
补充:VB , 基础类