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

投稿日: 2004/02/04(Wed) 11:47
投稿者ak
Eメール
URL
タイトルサンプル(改)

下記サンプルを試してみてください。

'(*.Frm)フォームにTextBoxを配列で数個配置してください。(Text1(0)〜Text1(n))
Option Explicit

Private Sub Form_Load()
    Dim ii  As Integer
    
    Me.KeyPreview = True
    
    For ii = Text1.LBound To Text1.UBound
        Text1(ii).MaxLength = ii + 2
    Next ii
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If TypeOf Screen.ActiveControl Is TextBox Then
        If KeyCode = 13 And Shift = 0 Then
            SendKeys "{TAB}"
        ElseIf KeyCode = 13 And Shift = 1 Then
            SendKeys "+{TAB}"
        ElseIf KeyCode = 46 Then
            KeyCode = 0 'Del無効
        End If
    End If
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If TypeOf Screen.ActiveControl Is TextBox Then
        If KeyAscii = 8 Or KeyAscii = 13 Then KeyAscii = 0   'BS無効
    End If
End Sub

Private Sub Text1_Change(Index As Integer)
    If Text1(Index).MaxLength = Len(Text1(Index)) Then SendKeys "{TAB}"
End Sub

Private Sub Text1_GotFocus(Index As Integer)
    '反転表示
    Text1(Index).SelStart = 0
    Text1(Index).SelLength = Len(Text1(Index))
End Sub


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

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

- Web Forum -