‘영문 숫자만 입력가능 하게 만든 함수 (일일이 적기 귀찮아서 만들었음)
Public Function CharacterMode(KeyAscii As Integer, Mode As Integer, Optional CharacterCode1 As Integer, Optional CharacterCode2 As Integer) As Integer
‘mode:’영문 0 ‘숫자 1 ‘영문+숫자 2
”’22 Ctrl+V
”’3 Ctrl+C
”’24 Ctrl+X
’66~90 :A~Z 97~122 :a~z
’48~57 :0~9
’47 : / ,
‘8 : backspace,
‘tab, enter 등은 필요하시면 추가. 도움말에서 Ascii 찾기
Select Case Mode
Case 0 ‘영문
If KeyAscii <> 3 And KeyAscii <> 22 And KeyAscii <> 24 And _
KeyAscii <> 8 And _
KeyAscii <> CharacterCode1 And _
KeyAscii <> CharacterCode2 And _
(KeyAscii < 65 Or KeyAscii > 90) And (KeyAscii < 97 Or KeyAscii > 122) Then
KeyAscii = 0 ‘제외하기
End If
Case 1 ‘숫자
If KeyAscii <> 3 And KeyAscii <> 22 And KeyAscii <> 24 And _
KeyAscii <> 8 And _
KeyAscii <> CharacterCode1 And _
KeyAscii <> CharacterCode2 And _
(KeyAscii < 48 Or KeyAscii > 57) Then
KeyAscii = 0 ‘제외하기
End If
Case 2 ‘영문+숫자
If KeyAscii <> 3 And KeyAscii <> 22 And KeyAscii <> 24 And _
KeyAscii <> 8 And _
KeyAscii <> CharacterCode1 And _
KeyAscii <> CharacterCode2 And _
(KeyAscii < 65 Or KeyAscii > 90) And (KeyAscii < 97 Or KeyAscii > 122) And _
(KeyAscii < 48 Or KeyAscii > 57) Then
KeyAscii = 0 ‘제외하기
End If
End Select
If KeyAscii >= 97 And KeyAscii <= 122 Then ‘대문자로
KeyAscii = KeyAscii – 32
End If
CharacterMode = KeyAscii
End Function