深圳全飞鸿
标题:
VB加入简单的防SQL注入
[打印本页]
作者:
syant
时间:
2019-5-4 11:56
标题:
VB加入简单的防SQL注入
本帖最后由 syant 于 2019-5-4 12:41 编辑
VB加入简单的防SQL注入
Private Sub TextInput_Keypress(KeyAscii As Integer)
On Error GoTo TextInput_KeyPress_Error
If Chr(KeyAscii) = "'" Then KeyAscii = 0
If Chr(KeyAscii) = ";" Then KeyAscii = 0
KeyAscii = TextFilter(KeyAscii, AlphaCap)
If KeyAscii = 13 Then
...
GoTo result
...
result:
TextInput.SetFocus
TextInput.SelStart = 0
TextInput.SelLength = Len(TextInput.text)
End If
Exit Sub
TextInput_KeyPress_Error:
MsgBox Err.Description, vbExclamation
End Sub
复制代码
作者:
syant
时间:
2019-5-4 12:31
Public Function TextFilter(fAsc As Integer, fMode As Integer) As Integer
On Error GoTo ErrorHandle
Select Case fMode
Case NumOnly 'Number Only
TextFilter = IIf(fAsc >= 48 And fAsc <= 57 Or fAsc = 8, fAsc, 0)
Case NumPoint 'Number & char '.'
TextFilter = IIf(fAsc >= 48 And fAsc <= 57 Or fAsc = 46 Or fAsc = 8, fAsc, 0)
Case NumTime 'Number & char ':'
TextFilter = IIf(fAsc >= 48 And fAsc <= 57 Or fAsc = 58 Or fAsc = 8, fAsc, 0)
Case AlphaCap 'Alpha Caption
If fAsc = 39 Then fAsc = 0
TextFilter = IIf(fAsc >= 97 And fAsc <= 122, fAsc - 32, fAsc)
End Select
Exit Function
ErrorHandle:
MsgBox Err.Description, vbCritical
End Function
复制代码
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2