16,554
社区成员
发帖
与我相关
我的任务
分享
'自動タブ押しメソッド
'引数1:入力中のテキストボックス・コンボボックス(Textプロパティがあるもの)
'引数2:その項目の規定サイズ
Public Sub AutoTab(ByRef LoControl As System.Windows.Forms.Control, ByRef LiStrSize As Short, Optional ByRef LvWakId As Object = Nothing)
Static LiLastSize As Short
Static LoLastControlhWnd As Integer
Static LsLastText As String
Dim LsNowText As String
'Dim LsConvType As String 使用されないローカル変数 削除必要
Dim LbWakId As Boolean
'引数省略時は枠IDではないと判断
If VarType(LvWakId) = VariantType.Error Then
LbWakId = False
Else
LbWakId = CBool(LvWakId)
End If
LsNowText = LoControl.Text
If Not LoControl.Handle.ToInt32 = LoLastControlhWnd Then
LoLastControlhWnd = LoControl.Handle.ToInt32
LiLastSize = 0
End If
Select Case LbWakId
Case False
If Len(LsNowText) = LiStrSize Then
If Len(LsNowText) - LiLastSize = 1 Then
If Not VB6.GetActiveControl() Is Nothing Then
If VB6.GetActiveControl().Handle.ToInt32 = LoControl.Handle.ToInt32 Then
System.Windows.Forms.SendKeys.SendWait("{TAB}")
If TypeOf VB6.GetActiveControl() Is System.Windows.Forms.Button Then
If VB6.GetActiveControl().Text = "..." Then
System.Windows.Forms.SendKeys.SendWait("{TAB}")
End If
End If
End If
End If
End If
Else
LiLastSize = Len(LsNowText)
End If
Case True
Select Case Mid(LsNowText, 5, 1)
Case "T", "t", "/"
If Not VB6.GetActiveControl() Is Nothing Then
If VB6.GetActiveControl().Handle.ToInt32 = LoControl.Handle.ToInt32 Then
System.Windows.Forms.SendKeys.SendWait("{TAB}")
If TypeOf VB6.GetActiveControl() Is System.Windows.Forms.Button Then
If VB6.GetActiveControl().Text = "..." Then
System.Windows.Forms.SendKeys.SendWait("{TAB}")
End If
End If
End If
End If
Case "S", "s", "-"
If Len(LsNowText) = 6 Then
If Len(LsNowText) - LiLastSize = 1 Then
If Not VB6.GetActiveControl() Is Nothing Then
If VB6.GetActiveControl().Handle.ToInt32 = LoControl.Handle.ToInt32 Then
System.Windows.Forms.SendKeys.SendWait("{TAB}")
If TypeOf VB6.GetActiveControl() Is System.Windows.Forms.Button Then
If VB6.GetActiveControl().Text = "..." Then
System.Windows.Forms.SendKeys.SendWait("{TAB}")
End If
End If
End If
End If
End If
Else
LiLastSize = Len(LsNowText)
End If
Case Else
If Len(LsNowText) = LiStrSize Then
If Len(LsNowText) - LiLastSize = 1 Then
If Not VB6.GetActiveControl() Is Nothing Then
If VB6.GetActiveControl().Handle.ToInt32 = LoControl.Handle.ToInt32 Then
System.Windows.Forms.SendKeys.SendWait("{TAB}")
If TypeOf VB6.GetActiveControl() Is System.Windows.Forms.Button Then
If VB6.GetActiveControl().Text = "..." Then
System.Windows.Forms.SendKeys.SendWait("{TAB}")
End If
End If
End If
End If
End If
Else
LiLastSize = Len(LsNowText)
End If
End Select
End Select
LsLastText = LsNowText
End Sub