好像沒這個功能吧﹐關注中只能判斷是字母還是數字的有﹐排除法吧﹐呵呵,要是小日本語﹐韓國語挂了。 判斷漢字好像不行。 A=inputbox("输入.......") select case asc(A) case 48 to 57 msgbox "数字。" case 65 to 90 msgbox "大写字母。" case 97 to 122 msgbox "小写字母。" case else msgbox "其他字符。" end select
Dim aa$, i%, HexStr$, HexVal&, IsEngNum As Boolean Private Sub Command1_Click() aa = InputBox("ÊäÈë.......") If aa <> "" Then IsEngNum = False For i = 1 To Len(aa) HexStr = Hex(Asc(Mid(aa, i, 1))) HexVal = Val("&H" + Mid(HexStr, 1, 2)) * 256 + Val("&H" + Mid(HexStr, 3, 2)) If HexVal < 45217 Or HexVal > 63486 Then IsEngNum = True: Exit For Next i MsgBox IIf(IsEngNum, "ÊäÈëµÄÄÚÈÝÓзǺº×Ö", "ÊäÈëµÄÄÚÈÝÖ»Óкº×Ö") End If End Sub
Dim aa$, i%, HexStr$, HexVal&, IsEngNum As Boolean Private Sub Command1_Click() aa = InputBox("输入.......") If aa <> "" Then IsEngNum = False For i = 1 To Len(aa) HexStr = Hex(Asc(Mid(aa, i, 1))) HexVal = Val("&H" + Mid(HexStr, 1, 2)) * 256 + Val("&H" + Mid(HexStr, 3, 2)) If HexVal < 45217 Or HexVal > 63486 Then IsEngNum = True: Exit For Next i MsgBox IIf(IsEngNum, "输入的内容有非汉字", "输入的内容只有汉字") End If End Sub
1.先要子类化窗体,捕获窗体的WM_Activate消息, 2.如果截获到弹出Inputbox(类名为#32770),再用 EnumChildWindows lParam, AddressOf EnumChildProc, ByVal 0&Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long Select Case GetWindowClassName(hwnd) Case "Edit" ls=Getwindowlong(hwnd,gwl_style) setwindowlong hwnd,ls or ES_Number End Select
EnumChildProc = 1 End Function Public Function GetWindowClassName(ByVal m_hWnd As Long) As String Dim RetVal As Long, lpClassName As String lpClassName = Space(255) RetVal = GetClassName(m_hWnd, lpClassName, 255) ThisWindowClassName = Left$(lpClassName, RetVal)End Function
判斷漢字好像不行。
A=inputbox("输入.......")
select case asc(A)
case 48 to 57
msgbox "数字。"
case 65 to 90
msgbox "大写字母。"
case 97 to 122
msgbox "小写字母。"
case else
msgbox "其他字符。"
end select
如果是用的inputbox,那就只能输入完后,再mid()一位一位取,hex(asc(XXX)),把不是汉字的过滤掉了。
Private Sub Command1_Click()
aa = InputBox("ÊäÈë.......")
If aa <> "" Then
IsEngNum = False
For i = 1 To Len(aa)
HexStr = Hex(Asc(Mid(aa, i, 1)))
HexVal = Val("&H" + Mid(HexStr, 1, 2)) * 256 + Val("&H" + Mid(HexStr, 3, 2))
If HexVal < 45217 Or HexVal > 63486 Then IsEngNum = True: Exit For
Next i
MsgBox IIf(IsEngNum, "ÊäÈëµÄÄÚÈÝÓзǺº×Ö", "ÊäÈëµÄÄÚÈÝÖ»Óкº×Ö")
End If
End Sub
Private Sub Command1_Click()
aa = InputBox("输入.......")
If aa <> "" Then
IsEngNum = False
For i = 1 To Len(aa)
HexStr = Hex(Asc(Mid(aa, i, 1)))
HexVal = Val("&H" + Mid(HexStr, 1, 2)) * 256 + Val("&H" + Mid(HexStr, 3, 2))
If HexVal < 45217 Or HexVal > 63486 Then IsEngNum = True: Exit For
Next i
MsgBox IIf(IsEngNum, "输入的内容有非汉字", "输入的内容只有汉字")
End If
End Sub
2.如果截获到弹出Inputbox(类名为#32770),再用
EnumChildWindows lParam, AddressOf EnumChildProc, ByVal 0&Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long Select Case GetWindowClassName(hwnd)
Case "Edit"
ls=Getwindowlong(hwnd,gwl_style)
setwindowlong hwnd,ls or ES_Number
End Select
EnumChildProc = 1
End Function
Public Function GetWindowClassName(ByVal m_hWnd As Long) As String
Dim RetVal As Long, lpClassName As String lpClassName = Space(255)
RetVal = GetClassName(m_hWnd, lpClassName, 255)
ThisWindowClassName = Left$(lpClassName, RetVal)End Function
End Function
以上就是通过截获msgbox后,改变msgbox的样式和子窗口的位置
在这个基础上再用 正则表达式 判断http://topic.csdn.net/u/20080507/17/d31bf1af-a3a0-417d-b52b-dbd20e4c0221.html这里的代码可以帮到你~