Printing the Ascii code of a string into a text box.
Hi all,
I need a code that will do as the title suggests, take a string, letter by letter, and print out the ascii code to a text box of each letter. I have not used Visual Basic for quite some time, and remember learning how to do this, but forgot how.
Thanks in advance.
Chris
1 Attachment(s)
Re: Printing the Ascii code of a string into a text box.
Add text1 and txtout and a command button:
VB Code:
Option Explicit
Dim x As Integer
Dim z As Integer
Private Sub Command1_Click()
x = Len(Text1.Text)
For z = 1 To x
txtout.Text = txtout.Text & Asc(Mid(Text1.Text, z, 1)) & " "
Next z
End Sub
Private Sub Form_Load()
Text1.Text = ""
txtout.Text = ""
End Sub
Re: Printing the Ascii code of a string into a text box.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
If Text1.Text = vbNullString Then Exit Sub
For i = 1 To Len(Text1.Text)
Text2.Text = Text2.Text & Asc(Mid$(Text1.Text, i, 1)) & ";"
Next
End Sub
Re: Printing the Ascii code of a string into a text box.
I almost decided to use dynamic textboxes for the answers, but changed my mind. I must have worked for a good 5 minutes. Hope you enjoy it :wave:
Re: Printing the Ascii code of a string into a text box.
Re: Printing the Ascii code of a string into a text box.