'text2 对应的反序的字符串
'command1 对应的 分离并反序按钮
'command2 对应的清除按钮
'其中 a 对应的 ascii 码 为97 z 对应的 ascii 码 为122
'A 对应的 ascii 码 为65 Z 对应的 ascii 码 为90
Private Sub Command1_Click()
''计算反码
If Text1.Text <>"" Then
For i = 0 To Len(Text1.Text) - 1
c = Mid(Text1.Text, Len(Text1.Text) - i, 1)
If Asc(c) >65 And Asc(c) <90 Or Asc(c) >97 And Asc(c) <122 Then
''是字母,则输出显示
Text2.Text = Text2.Text &c
Else
End If
Next
End If
End Sub
Private Sub Command2_Click()
''清除
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
是不是这个效果?建一个Text1。代码如下。
==========================
Private Sub Form_Load()
Text1.Locked = True
Text1.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKey0 To vbKey9
Text1.Text = Text1.Text + Chr(KeyAscii)
Case vbKeyDelete
If InStr(1, Text1.Text, ".") = 0 Then Text1.Text = Text1.Text + "."
Case vbKeyBack
If Len(Text1.Text) >0 Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Select
End Sub
public Function DeleteChars(text as String) as String)dim s as string : s=`~!@#$%^&*()_-+=[{]}\|:' &Chr(34) &",<.>?/"
dim result as String :result=text
dim i as long
for i =1 to Len(s)
result=Replace(result,mid(s,i,1),"")
next
DeleteChars= result
End Function
----------------------------------------------------------------
a="`~!@#$%^&*()_-+=[{]}\|:'",<.>?/"
for i=1 to len(a)
b=asc(mid(a,i,1))
if b>32 and b<48 then else '过滤ASCII 33-47的字符
if b>57 and b<65 then else '过滤ASCII 58-64的字符
c=c &mid(a,i,1)
end if
end if
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)