小问题请教高手帮忙!!!(送分啊!)

jxl569 2003-12-27 08:17:41
如何在"txt"中把如下“—#*……*……()·——!)(*#¥——¥)”等等乱码给过滤掉。

不让用户输入
...全文
54 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2003-12-27
  • 打赏
  • 举报
回复
rainstormmaster(rainstormmaster) 提供的是最实用的代码,若只想输入数字和字母,可以这样:
Private Sub Form_Load()
Me.KeyPreview = True
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = IIf((Abs(KeyAscii - 53) <= 5 Or Abs(KeyAscii - 77) <= 13 Or Abs(KeyAscii - 110) <= 13), KeyAscii, 0)
End Sub
sdjack 2003-12-27
  • 打赏
  • 举报
回复
在keyperss事件中写入处理代码呀。
jxl569 2003-12-27
  • 打赏
  • 举报
回复
谢谢你了.按你的方法太麻烦了!!要把所有乱码都输入才可以..
rainstormmaster 2003-12-27
  • 打赏
  • 举报
回复
Option Explicit
Dim s As String
Private Sub Form_Load()
s = "“—#*……*……()·——!)(*#¥——¥)”"
Debug.Print s
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim i As Long, ss As String, j As Long
ss = Chr(KeyAscii)
i = InStr(1, s, ss)

If InStr(1, s, ss) > 0 Then
KeyAscii = 0
End If

End Sub
大致是这个意思吧

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧