VB6.0用掲示板の過去のログ(No.1)−VBレスキュー(花ちゃん)
[記事リスト] [新規投稿] [新着記事] [ワード検索] [過去ログ] [管理用]

投稿日: 2004/02/04(Wed) 11:53
投稿者いちゆ
Eメール
URL
タイトルRe: 入力文字数でのフォーカス制御

じゃ、これは?

Const TextBox1_MaxLength = 10

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim i  As Long
Dim st As String
Select Case KeyAscii
    Case vbKeyReturn
        TextBox2.SetFocus
    Case Else
        TextBox1.SelLength = 0
        st = TextBox1.Text
        If Mid$(st, TextBox1.SelStart + 1, 1) <> "" Then
            i = TextBox1.SelStart
            Mid$(st, TextBox1.SelStart + 1, 1) = ChrW$(KeyAscii)
            TextBox1.Text = st
            TextBox1.SelStart = i + 1
            KeyAscii = 0
        End If
            
        If Len(TextBox1.Text) >= TextBox1_MaxLength Then
            KeyAscii = 0
            TextBox1.Text = Left$(TextBox1.Text, TextBox1_MaxLength)
            TextBox2.SetFocus
        End If
End Select
End Sub


- 関連一覧ツリー (★ をクリックするとツリー全体を一括表示します)

- 返信フォーム (この記事に返信する場合は下記フォームから投稿して下さい)

- Web Forum -