VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 2145 ClientLeft = 5520 ClientTop = 4920 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 2145 ScaleWidth = 4680 Begin VB.TextBox Text1 Height = 375 Left = 600 TabIndex = 0 Top = 1080 Width = 3375 End Begin VB.Label Label3 Caption = "半角の大文字のみ入力可" Height = 180 Left = 1200 TabIndex = 3 Top = 720 Width = 1980 End Begin VB.Label Label2 Caption = " BY MADIA" Height = 180 Left = 3240 TabIndex = 2 Top = 1800 Width = 1110 End Begin VB.Label Label1 Caption = "< テキストボックスの文字制御サンプルです >" Height = 180 Left = 480 TabIndex = 1 Top = 240 Width = 3765 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then '処理無し Exit Sub Else '文字が A - Z 以外の時の処理 MsgBox "A 〜 Z の半角の大文字しか入力できません!!!" 'KeyAscii = 0 とは入力した文字(キー)情報のクリアです KeyAscii = 0 Text1.Text = NullSTRING Beep End If End Sub