數(shù)字錄入驗(yàn)證:使用正則驗(yàn)證,同C# Dim reg1 As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("^(?:\+|-)?\d+(?:\.\d+)?$") If Not reg1.IsMatch(TextBox1.Text) Then MsgBox("fase"):TextBox1.Focus() 使用VB.Net中函數(shù) If Not IsNumeric(TextBox1.Text) Then MsgBox("fase") TextBox1.Focus() End If 漢字錄入驗(yàn)證辦法一:使用正則表達(dá)式 If New System.Text.RegularExpressions.Regex("[\u4e00-\u9fa5]").Match(txt.Text).Success Then ’輸入框中包含有漢字,則采用模糊匹配 Cols = Cols.Replace(",", " like ’%" & txt.Text & "%’ or ") Cols &= " like ’%" & txt.Text & "%’ " Else ’輸入框中不包含有漢字,則采用精確匹配 Cols = Cols.Replace(",", " = ’" & txt.Text & "’ or ") Cols &= " = ’" & txt.Text & "’ " End If 方法二,使用長(zhǎng)度判斷 If System.Text.Encoding.Default.GetBytes(txt.Text).Length = txt.Text.Length Then ’有漢字
End If
|