|
テキストボックスが5個として
(クラスも何も使わず、素直?に書くと)
シートモジュール
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Call 移動(KeyCode, 1)
End Sub
Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Call 移動(KeyCode, 2)
End Sub
Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Call 移動(KeyCode, 3)
End Sub
Private Sub TextBox4_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Call 移動(KeyCode, 4)
End Sub
Private Sub TextBox5_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Call 移動(KeyCode, 5)
End Sub
'標準モジュール
Sub 移動(KeyNo, No)
If KeyNo = vbKeyTab Then
If No >= 5 Then
No = 1
Else
No = No + 1
End If
ActiveSheet.OLEObjects("TextBox" & No).Activate
End If
End Sub
|
|