vb编程,ASCII转换问题

2024-12-16 01:02:53
推荐回答(4个)
回答1:

dim a as string
dim n as string
n=""
for i=1 to len(text1.text)
a=trim(left(text1.text,i,1))
n=n+chr(asc(a)+10)
next i
text1.text=n
这是每个都加一下,如果只是再后面加个字符也一样!
dim a as string
dim n as srting
n=""
for i =1 to len(text1.text)
a=trim(left(text1.text,i,1))
n=n&a+"....."
next i
如果你是给密码加密的话,最好不要+自定义的字符,加ASC码
dim a as string
dim n as string
n=""
for i= 1 to len(text1.text)
a =trim(left(text1.text,i,1))
n=n+a+asc(65+i)
next i
text1.text=n

回答2:

一串字符的asc码+ 10还是单个?描述有问题?

////////////////////字符串
Private Sub Command3_Click()
Dim Str() As Byte
Dim str2 As String
Dim e

Str = Text1.text
For Each e In Str
If e <> 0 Then '不连接空字符
e = e + 10
str2 = str2 & Chr(e)
End If
Next
MsgBox str2
End Sub
////////////这个方法效率要比上面一种高
请用无数个"ssssssssssssssss......"测试

回答3:

Private sub Command1_Click()
dim s as string
dim i as integer
for i=1 to len(text1.text)
s=s & chr(asc(mid(text1.text,i,1))+10)
next i
text1.text=s
End sub

回答4:

Private Sub Command1_Click()
Dim TempStr As String, i As Integer
For i = 1 To Len(Text1)
TempStr = TempStr & Chr(Asc(Mid(Text1, i, 1)) + 10)
Next
Text2 = TempStr
End Sub

Private Sub Form_Load()
Text1 = "123456"
End Sub