converting letters to ascii values

Say I have a textbox that has the text value of "Hello world".
Is there any way I could convert "Hello world" into its ascii value?
For instance, the ascii value for "Hello" is 72-69-76-76-79. Is there any way I could convert "Hello" or any other word that is found in a text box to its ascii value without having to go through it and type

If Mid(strLetter, 1, 1) = "a" then print "65"
if Mid(strLetter, 1, 1) = "b" then print "66"

that seems very tedious to me.

Thanks.

Comments

  • Yes you certainly can:
    [code]
    [green]'Give Dimension To Variables[/green]
    [blue]Dim[/blue] strMsg [blue]As String[/blue], n [blue]As Integer[/blue]
    [blue]Dim[/blue] TempMsg [blue]As String[/blue]

    [green]'Convert And Gather Ascii Values[/green]
    strMsg = txtMsg [green]'txtMsg = "Hello World"[/green]
    [blue]For[/blue] n = 1 [blue]To[/blue] Len(strMsg)
    [blue]If[/blue] TempMsg = "" [blue]Then[/blue]
    TempMsg = Asc(Mid$(strMsg, n, 1))
    [blue]Else[/blue]
    TempMsg = TempMsg & "-" & Asc(Mid$(strMsg, n, 1))
    [blue]End If[/blue]
    [blue]Next[/blue] n

    [green]'Display Output[/green]
    MsgBox "The Ascii value of this word in full is:" & vbCrLf & TempMsg

    [green]'Clean Up[/green]
    strMsg = ""
    n = 0
    TempMsg = ""
    [/code]

    I hope this helps as well as works!!

    ..:: Zantos ::..
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion