正常做法是从原始字符串中依次取出每个字符,加1并按规则转换之后连接成新的字符串,参考代码:
For i = 1 To Len(Text1.Text)
c = Mid(Text1.Text, i, 1)
t = Val(c) + 1
If t = 10 Then
Text2.Text = Text2.Text & "A"
Else
Text2.Text = Text2.Text & t
End If
Next i
这里再提供一个【原位】【使用Hex函数】转换的“偏门”方法:
s = Text1.Text
For i = 1 To Len(s)
Mid(s, i, 1) = Hex(Val(Mid(s, i, 1)) + 1)
Next i
Text2.Text = s
For i = 1 To Len(Text1.Text)
c = Mid(Text1.Text, i, 1)
t = Val(c) + 1
If t = 10 Then
Text2.Text = Text2.Text & "A"
Else
Text2.Text = Text2.Text & t
End If
Next i
这里再提供一个【原位】【使用Hex函数】转换的“偏门”方法:
s = Text1.Text
For i = 1 To Len(s)
Mid(s, i, 1) = Hex(Val(Mid(s, i, 1)) + 1)
Next i
Text2.Text = s

七奈