|
Sorry about that. Thanks for your help. I think my for loop is not working and the words had to be generate in listbox
|
|
|
|
|
To try to understand what you want obtain, I need to know:
In this piece of your code:
Numbers(0, 0) = "A"
Numbers(0, 1) = "B" '2
Numbers(0, 2) = "C" '2
Numbers(1, 0) = "D" '3
Numbers(1, 1) = "E" '3
Numbers(1, 2) = "F" '3
Numbers(2, 0) = "G" '4
Numbers(2, 1) = "H" '4
Numbers(2, 2) = "I" '4
Numbers(3, 0) = "J" '5
Numbers(3, 1) = "K" '5
Numbers(3, 2) = "L" '5
Numbers(4, 0) = "M" '6
Numbers(4, 1) = "N" '6
Numbers(4, 2) = "O" '6
Numbers(5, 0) = "P" '7
Numbers(5, 1) = "R" '7
Numbers(5, 2) = "S" '7
Numbers(6, 0) = "T" '8
Numbers(6, 1) = "U" '8
Numbers(6, 2) = "V" '8
Numbers(7, 0) = "W" '9
Numbers(7, 1) = "X" '9
Numbers(7, 2) = "Y" '9
Do you forgotten the comment "'2" in the first line?
And do you forgotten the letter "Q" in the list?
Words must be without letter "Q"?
modified on Sunday, September 6, 2009 6:39 PM
|
|
|
|
|
there is no Q in the list my problem does't have a letter Q assign to any number and yes I did not comment in the first line I don't think it is a problem.
Thank you
|
|
|
|
|
Here are a few ideas to give you a start.
It is just a form with a TextBox (txtResult) and a Button (btnGenerate). I am using a TextBox because I am only doing 1 possibility (you wouldn't want me to deprive you of the fun of doing it yourself, now, would you? ), but you are right ListBox is the way to go. In fact you might want to consider using 3 (or 4 if you allow for the possibility that some keys have 4 possibilities) ListBox es.
Any way here is what I thought you might use.
Dim input As String = "4247288"
Dim characterLookup As Dictionary(Of Char, Char()) = New Dictionary(Of Char, Char())
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.FillCharacterLookup()
End Sub
Private Sub FillCharacterLookup()
characterLookup.Add("2"c, New Char() {"A"c, "B"c, "C"c})
characterLookup.Add("3"c, New Char() {"D"c, "E"c, "F"c})
characterLookup.Add("4"c, New Char() {"G"c, "H"c, "I"c})
characterLookup.Add("5"c, New Char() {"J"c, "K"c, "L"c})
characterLookup.Add("6"c, New Char() {"M"c, "N"c, "O"c})
characterLookup.Add("7"c, New Char() {"P"c, "Q"c, "R"c, "S"c})
characterLookup.Add("8"c, New Char() {"T"c, "U"c, "V"c})
characterLookup.Add("9"c, New Char() {"W"c, "X"c, "Y"c, "Z"c})
End Sub
Private Sub OutputResult()
Dim outArray(7) As Char
For index As Integer = 0 To input.Length - 1
outArray(index) = characterLookup(input(index))(0)
Next
Me.txtResult.Text = Convert.ToString(outArray)
End Sub
Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
Me.OutputResult()
End Sub
If you put this code on a form, as described above, run it and click the Generate button you should get "GAGPATT" which is defined as the output from a Cow at an S & M party.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thank very much, but I have to display 2187 combinations in a list box after user enter the phone number in textbox
|
|
|
|
|
rbjanaki wrote: thank very much, but I have to display 2187 combinations in a list box after user enter the phone number in textbox
I know that. This means that you are not allowing 'Q' or 'Z', otherwise there would be more than that.
The sample code I gave you was just to demonstrate a method of obtaining the characters for the keys entered. What you have to do is to figure out a way to obtain all the possible combinations (729 for each of the possible start letters, in your example "4247288", that is 729 words starting with 'G', 729 for 'H' and 729 for 'I')
Putting them in a ListBox is trivial instead of Me.txtResult.Text = Convert.ToString(outArray) use Me.lboxResult.Items.Add(Convert.ToString(outArray)) .
As I said in my previous post "you don't really want me to deprive you of the fun of working out how to do it, do you?", besides, I doubt that you could afford my rates.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: I will have to think about it
Yeah, I don't know where to get a haircut on a Sunday evening either.
|
|
|
|
|
Luc Pattyn wrote: Yeah, I don't know where to get a haircut on a Sunday evening either.
What a backward place you must live in.
I have a choice from 2,187 possibilities.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: I have a choice from 2,187 possibilities
Too bad, as I know how hard it is for you to make even simple decisions...
|
|
|
|
|
Luc Pattyn wrote: Too bad, as I know how hard it is for you to make even simple decisions...
True!
It gets worse, I have just realized that there could be more options than that. I forgot that some keys have 4 characters!
BTW I forgot to 5 your previous post. Putting it right now.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: I forgot to 5 your previous post.
I bet you also forgot to take your pills. Again.
|
|
|
|
|
Stop it, I'll fall off!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi all,
I need that application I'm developing can consider the same (=), 3 strings for example like these:
String A = "This, is, a, sample, 12345"
String B = "this, is,a, Sample ,12345"
String C = "This,is,a,sample,12345"
Someone know if there is a simple way (may be a single instruction?) to do that?
I know how to do that, but it is not a simple way.
Thanks
Ignazio
modified on Saturday, September 12, 2009 2:09 PM
|
|
|
|
|
your question is unclear. IF what you want is a way to compare two strings ignoring white space, ignoring comma's and ignoring case, then the solution is two write a function MyStringCompare(ByVal string1 as String, ByVal string2 as String) as Integer wherein you first remove white space and comma's, and then use the built-in string compare function, telling it to ignore case.
If that is unclear to you, I strongly advice you to buy and study a book on the programming language of your choice.
|
|
|
|
|
Hi,
Yes, I need a way to compare 2 strings, ignoring spaces and case.
In the end of my question, I written that I know how to do that, but I was hoping that someone know a simpler way, or may be an already built-in instruction in V.B. to do this work.
Thanks for help and for "advice"
Ignazio
|
|
|
|
|
can you explain it little more what is your point if i am not wrong do you want that you have same string but in different cases and spaces and you want it to be consider as same
is this your question or what ????
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
|
You can do a case insensitive comparison easy enough. I don't know there's a way to ignore spaces without actually removing them.
String.Compare takes a bool to say if it's case sensitive.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
That for me has prioritary importance, is the problem of spaces.
The case insensitive comparation is a secondary requirement.
It seems that I can't avoid the work to delete spaces.......
Ignazio
|
|
|
|
|
No, because you're creating an odd definition of 'equal'. You may be able to use regex to create a string that allows arbitrary spaces between each character, but it seems like more work than just stripping them, to me.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks for help,
I will evaluate what is more convenient to do.
Strings that I must compare can have until 23 commas!
Ignazio
|
|
|
|
|
hope so this will work , I did this thing for you but MVPs don't recommend this because copy paste will not enhance your programing skills
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str1, str2 As String
str1 = "softdev_sup"
str2 = "Softdev_ sup"
MessageBox.Show(String.Compare(str1, str2, False))
MessageBox.Show(String.Compare(RemoveSpace(str1), RemoveSpace(str2), True))
End Sub
Public Function RemoveSpace(ByVal strText As String) As String
Return System.Text.RegularExpressions.Regex.Replace(strText, " ", _
String.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
End Function
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Hi,
The code you posted seems to be exactely that I was looking for.
With great surprise, differentely I was thinking, it is also fully compliant with Compact Framework, without any modification.
Running the code, the first message is "1" and second is "0".
To reduce the impact on the programing skills, I will do the work in 2 steps:
A first pass will exclude strings 100% equal (considering also spaces), from the 2nd pass that will compare only remaining strings using the RemoveSpace function.
Thank you very much.
Ignazio
modified on Monday, September 7, 2009 12:44 PM
|
|
|
|
|
u r welcome man say thanks 2 code project
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Dear All,
i am VB.Net User with Visual Studio.Net i want to genrate a project for FM Radio. They have some secrete MP3 files. So, they want to store them in there Data Base.
Dear All my Question is that how can i do that Using Visual Studio with Visual Basic.Net. If Someone has complete knowledge about this so plz help me.
Waiting for ur reply
Abdul Rouf
|
|
|
|
|