• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Visual Studio .net Programming Help. Read in a single character

austin316

Diamond Member
Ok, I have a simple question that I don't know how to answer. The user enters a word into a text box, and I need to read that word as individual characters. IE. user enters the word "apple" and I want to read that as A, P, P, L, E. Then those letters would get converted into numbers, through a simple case statement. Thanks in advance.
 
The TextBox is inherited from Control as a property returning a String. As such, you can access any individual character using the indexer:

string testString = "apple";
//testString[0] == 'a'
//testString[1] == 'b'

etc.

If you're using VB.NET, just use the Chars property of the string instead:

Dim testString As String = "apple"
' testString.Chars(0)
' testString.Chars(1)

etc.
 
Back
Top