I just ran into an assignment that says: let the user enter a word, then displays the "Unicode base 10 number" for "each" letter in that word.

Example: enter "Aretha", the label should then display
"A = 65 r = 114 e = 101 t = 116 h = 104 a = 97"

Here is my code so far:

Dim intCharCode As Integer
intCharCode = AscW("..... what???.....")

That's where i struggle. I don't know what to put after "AscW". Because if I use Substring to locate the "first letter" of the word, then the label would only display the Unicode for that one single letter. I can pretty much use Substring to continue to locate the remaining letter of the word.

The problem is: I dont know how long the word is gonna be. I mean, I have to know when the word ends.

I there any solution to my problem?

Are you familiar with loops? For Each, specifically? How about arrays?

If so, you might want to try a loop wrapped around an array of characters. You can create that array with a string's .ToCharArray() method.

yourStringVariable.ToCharArray()

You can then convert each individual character to an integer and do whatever you need to do to finish the assignment.

linq is your friend
try this out

Dim InputText As String = "vbnetskywalker"
        Dim Letters = From c As Char In InputText.ToCharArray _
                      Select c & " = " & AscW(c) & " "
        MsgBox(String.Join(vbCrLf, Letters.ToArray))

hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.