0

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?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by vbnetskywalker
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.