タイトル | : フォーカス移動 |
記事No | : 4354 |
投稿日 | : 2006/09/29(Fri) 11:07 |
投稿者 | : きむち |
いつも参考にさせて頂きありがとうございます。 VB6からVB2005にしたのですが、クラスモジュールを使用して『3桁の英数字が入力されたら、次のテキストボックスへ移動する。』処理をさせようとしているのですが上手く行きません。 どうかご教授お願い致します。
Public Class Form1 Public TBox(20) As TextEvents Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim N As Integer For N = 1 To 5 TBox(N) = New TextEvents TBox(N).SlaveTextBox = New TextBox TBox(N).SlaveTextBox.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point) TBox(N).SlaveTextBox.CharacterCasing = CharacterCasing.Upper TBox(N).SlaveTextBox.ImeMode = Windows.Forms.ImeMode.Disable TBox(N).SlaveTextBox.TextAlign = HorizontalAlignment.Center TBox(N).SlaveTextBox.Width = 100 TBox(N).SlaveTextBox.Height = 20 TBox(N).SlaveTextBox.MaxLength = 3 TBox(N).SlaveTextBox.Location = New Point(0, (N - 1) * 25) Me.Controls.Add(TBox(N).SlaveTextBox) Next End Sub End Class
Public Class TextEvents Public WithEvents SlaveTextBox As TextBox Private Sub SlaveTextBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles SlaveTextBox.DoubleClick SlaveTextBox.Text = "" End Sub Private Sub SlaveTextBox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles SlaveTextBox.GotFocus SlaveTextBox.SelectionStart = 0 SlaveTextBox.SelectionLength = Len(SlaveTextBox.Text) SlaveTextBox.BackColor = Color.White End Sub Private Sub SlaveTextBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles SlaveTextBox.LostFocus SlaveTextBox.BackColor = Color.LightGray End Sub
Private Sub SlaveTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)Handles SlaveTextBox.TextChanged If Len(SlaveTextBox.Text) >= 3 Then
'***************************************************************************** '**************************************************************************** 'ここが上手くできません。 Me.SlaveTextBox.GetNextControl(sender, True).Focus() '**************************************************************************** '*****************************************************************************
End If End Sub End Class
|