Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Trouble: Display ASCII Values

I want to create an ASCII App that allows the user to enter a word, and then displays the ASCII value code for each letter of the word. Ex

Word: Aretha
A=65 r=144 e=101 t=116 h=104 a=97

I know i have to search the string given by the user, and display each character's ASCII value, but im not quite sure how to do so.

Thanks,
Tim.
[370 byte] By [tygolfer] at [2007-11-11 9:57:02]
# 1 Re: Trouble: Display ASCII Values
make this small function :

Function disp(str As String)
Dim i As Integer
Dim tmp As String
For i = 1 To Len(str)
tmp = Mid(str, i, 1)
disp = disp & tmp & "=" & Asc(tmp) & " "
Next
End Function

and here is the test :

Private Sub Command1_Click()
MsgBox disp("Aretha")
End Sub

it helps ?
Amahdy at 2007-11-11 17:23:29 >
# 2 Re: Trouble: Display ASCII Values
hmm..im having trouble laucnhing the app

i have:

strWord = txtWord.TEXT

then i want to display all the values using concatenation (&) in a labelbox: lblOutput.caption= "

how would that be written?
tygolfer at 2007-11-11 17:24:30 >
# 3 Re: Trouble: Display ASCII Values
strWord = txtWord.TEXT

in place of str put txtWord

(&) in a labelbox: lblOutput.caption=

in place of the retVal of the function use lblOutput.caption

well here is your example :

Dim i As Integer
Dim tmp As String
For i = 1 To Len(txtWord.TEXT)
tmp = Mid(txtWord.TEXT, i, 1)
lblOutput.caption = lblOutput.caption & tmp & "=" & Asc(tmp) & " "
Next

fine ?
Amahdy at 2007-11-11 17:25:27 >
# 4 Re: Trouble: Display ASCII Values
regarding lblOutput.caption must be empty before start filling :

lblOutput.caption = ""
Amahdy at 2007-11-11 17:26:33 >
# 5 Re: Trouble: Display ASCII Values
excellent, thanks alot!
tygolfer at 2007-11-11 17:27:34 >