テキストボックスに整数のみ入力



Homeに戻る > Excel テキストボックスのTipsへ

シートのVBAコード

コマンドボタンクリックイベント
'テキストボックス キー入力イベント
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    KeyAscii = KeyInputVal(KeyAscii)
End Sub



標準モジュールコード

'整数のみ入力
Public Function KeyInputVal(Key) As Integer
    If Key <> 8 Then
        If (Key < 48 Or Key > 57) Then
            Key = 0
        End If
    End If
    KeyInputVal = Key
End Function


Homeに戻る > Excel テキストボックスのTipsへ

■■■
このサイトの内容を利用して発生した、いかなる問題にも一切責任は負いませんのでご了承下さい
■■■
当ホームページに掲載されているあらゆる内容の無許可転載・転用を禁止します


Copyright (c) Excel-Excel ! All rights reserved