|
Enum Letters On Phone KeyPad And Convert -- Jon Turlington --
Here is what I have but it's definately not working. I am trying to have a text box with letters in it and if someone where to try entering a word from a phone keypad and it came out as numbers what those numbers would be. Here's my failing attempt but maybe some one can steer my ship in the right direction: <%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System.ComponentModel" %> " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> |
|
-- Jon Turlington --
Here is what I have but it's definately not working. I am trying to have a text box with letters in it and if someone where to try entering a word from a phone keypad and it came out as numbers what those numbers would be. Here's my failing attempt but maybe some one can steer my ship in the right direction: <%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System.ComponentModel" %> " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> |
|
-- Cerebrus --
Simple : In your Button Click event, change the For Each loop to : ------------------- For Each Chr In TextBox1.Text Label1.Text += CStr( .Parse(GetType(Phone), Chr.ToString(), True)) Next ------------------- What we're basically doing here, is supplying the string representation of the Enum and we want to get the numeric constant associated with it. The Parse method allows us to do that. Note that if an space is entered in the text, your program will give an exception. You can decide how to handle this. (Maybe you could substitute a 0 for spaces...) HTH, Regards, Cerebrus. |
|
-- JonTurlington --
Thanks alot for the help! I post things on the boards and they always seem ignored. Jon |
|
-- Cerebrus --
Well, some newsgroups have less activity, and some have so much activity, that it's difficult to keep up. I monitor a lot of groups including this one, but I'm usually found posting in < http://groups.google.com/group/DotNetDevelopment >Have a nice one, Regards, Cerebrus. |