VB 限制text文本框中只可以输入全角文字
1个回答
展开全部
'自定义长度函数
Private Function getlong(s As String)
Dim TempByte() As Byte
TempByte = StrConv(s, vbFromUnicode)
getlong = UBound(TempByte) + 1
End Function
Private Sub Text1_Change()
Dim s As String
s = Text1.Text
Dim mystr As String
mystr = ""
For i = 1 To Len(s)
If getlong(Mid(s, i, 1)) = 1 Then
MsgBox "非全角字符"
Else
mystr = mystr & Mid(s, i, 1)
End If
Next
Text1.Text = mystr
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询