'Set TAB auto when press key UP, DOWN, RETURN
Public Sub AutoTab(ByVal KeyCode As Integer)
If KeyCode = vbKeyDown Or KeyCode = vbKeyReturn Then
SendKeys "{TAB}", True
ElseIf KeyCode = vbKeyUp Then
SendKeys "+{TAB}", True
End If
End Sub
'Create hilight when textbox are focused
Public Sub HiLight(ByRef txt As Control)
If txt.Enabled = True And txt.Visible = True And (TypeOf txt Is TextBox Or TypeOf txt Is MaskEdBox Or TypeOf txt Is ComboBox) Then
txt.SelStart = 0
txt.SelLength = Len(txt.Text)
End If
End Sub
การใช้งาน
Private Sub Text1_GotFocus()
HiLight Me.ActiveControl
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
'จำเป็นต้องจัดลำดับ TabIndex ของ Textbox แต่ละตัวด้วย
AutoTab KeyCode
End Sub
ไม่มีความคิดเห็น:
แสดงความคิดเห็น