本文介绍了样本编码以限制特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vb6和vb.net中限制特殊字符的示例编码?

Sample codings to restrict special characters in vb6 & vb.net?

推荐答案

Option Explicit

'This will only accepts the alphabets and no other key is allowed.
Private Sub Text1_KeyPress(KeyAscii As Integer)
    If Not KeyAscii >= 65 And KeyAscii < 90 Then
        KeyAscii = 0
    End If
End Sub



VB.NET:使用KeyPressed进行验证...



VB.NET: Use KeyPressed for validation...

''Textbox KeyPress
'' Allow number 0-9 plus backspace, Del + Home + End will be accepted also
Dim ValidInputChar = "0123456789." + vbBack
If not ValidInputChar.Contains(e.KeyChar) then
    e.KeyChar=Nothing
End If



这篇关于样本编码以限制特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-02 18:40