在網頁或是win form程式中
如果在我們輸入的文字方塊中,只允許半型的文數字輸入時
可以透過以下的方法來檢查
如果回傳的值是False表示輸入的文數字中有全型的文數字
註:如果是asp.net的程式,請將這一段程式放在post back的程式碼裏面…
Private Function CheckInputCharType(ByVal stud_no As String) As Boolean
CheckInputCharType= True
Dim intAsc As Integer
Dim i As Integer = 0
For i = Len(stud_no) To 1 Step -1
intAsc = Asc(Mid(stud_no, i, 1))
If intAsc > 0 And intAsc Then
Else
Return False
End If
Next
End Function
全站熱搜