一個ASCII轉換的程式,但輸出的值比原ASCII大1,且輸出的每增加一位其值又加上相應的位數,如輸入的每一位+0,第二位加1………第N位+N-1,舉例:輸入123ABC,輸出為50,52,54,69,71,73.輸入1111由輸出為50,51,52,53,經常有混合輸入但,輸出均為十進制ASCII碼。
以下是代碼
Dim i As Integer
Dim a() As String
Private Sub Command1_Click()
If Text1 <> "" Then
i = 0
Text2 = ""
Timer1.Enabled = True
Else
MsgBox "請輸入內容!", 48, "提示"
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 10
End Sub
Private Sub Timer1_Timer()
Text3.Text = Asc(Mid(Text1.Text, Len(Text1.Text) - i, 1) + 1) + Len(Text1.Text) - i - 1
Text2.Text = Text3 + "," + Text2
i = i + 1
If i >= Len(Text1.Text) Then
Timer1.Enabled = False
End If
End Sub
運行結果為:只能輸入數字不能輸入字母及符號,當輸入9時出現49,應該是58的,懇求解決下為謝
uj5u.com熱心網友回復:
Sub ASCII碼()
Dim n As Integer
Dim i As Integer
Dim a As String
n = Len("一個ASCII轉換的程式問題請高手解決下!")
a = ""
For i = 1 To n
a = a & Asc(Mid("一個ASCII轉換的程式問題請高手解決下!", i, 1)) & ","
Next i
Debug.Print a
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/131265.html
標籤:VBA
上一篇:PLC編程與軟體編程區別?
下一篇:vb串口通信問題 急
