bluejaguar456 Posted October 28, 2008 Posted October 28, 2008 Hey Guys, I have been having a few problems trying to get all the letters in a textbox to split. I want to get any letters that the user types in a textbox to be split into each different letter. The end result will be that i can check each letter and cross reference it with a number. E.G. r returns 32, e returns 54 This is going to be done for every letter that the user types, Any help would be great appreciated! Thanks. Quote
Nate Bross Posted October 28, 2008 Posted October 28, 2008 I'm not sure, but you should be able to attach to the TextBox.KeyPressed Event which sould give you the keycode of the key that was pressed. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
anu Posted October 29, 2008 Posted October 29, 2008 substring keyword is for spliting the string. and use ascii function to determine the ascii value... Quote
Nate Bross Posted October 29, 2008 Posted October 29, 2008 If you want to do all the processing after the user is finished typing (not using an event like I mentioned earlier). You may use a foreach loop like this. foreach(char c in yourTextBox.Text) // perform action on c Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
bluejaguar456 Posted October 29, 2008 Author Posted October 29, 2008 is it possible to check each letter int eh order typed afterwards? e.g user types: hello i then check for the 'h' then the 'e' then the 'l' and so in order? thanks Quote
Nate Bross Posted October 30, 2008 Posted October 30, 2008 That is exactly what my code should do. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
bluejaguar456 Posted October 30, 2008 Author Posted October 30, 2008 ok will have a try thanks for your help :) Quote
bluejaguar456 Posted October 31, 2008 Author Posted October 31, 2008 this code is not working for this it is saying that char is a type and cannot used as an expression :confused: Quote
JumpyNET Posted November 1, 2008 Posted November 1, 2008 Is this what you are looking for: Dim TheChars() As Char = TextBox1.Text.ToCharArray() For Each TmpChar In TheChars Debug.Print(TmpChar & " = " & Asc(TmpChar)) Next Quote
Maninder Kaur Posted November 20, 2008 Posted November 20, 2008 This code can help u char[] textValue = textBox1.Text.ToCharArray(); foreach (char c in textValue) lblAsciiValue.Text += (int)©; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.