i have a masked word in a text box. i aslo have an array of 26 command buttons, with a letter of the alphabet on each of the buttons. i want to know how i could unmask a letter in the word in the txtbox if i click on one of the cmdLetters.:confused:
Printable View
i have a masked word in a text box. i aslo have an array of 26 command buttons, with a letter of the alphabet on each of the buttons. i want to know how i could unmask a letter in the word in the txtbox if i click on one of the cmdLetters.:confused:
Can you be more specific?? We can not guess what's what you're doing.
You mean like a hang-man type game?
ye kinda like hang man.
in the form i have a text box. 26 command buttons (array 0 to 25). each of the command buttons have a letter of the alphabet on it. so it looks like i have a keyboard on the form.
in the text box, there is a "word" and it is masked to look like "****".
i want to know how i could make the "****" back to "word" when i click on the "w" "o" "r" "d" command buttons. so i need to know some sort of code where i could un-mask the "****" in the text box. you know what i mean?
If you have a different label for each letter (on the word), write each masked letter on its tag. Then, each time a key (command array) is preseed, loop among all fo your labels and check if their tags are the same as the letter. If any of them does, just turn its caption to the same value of its tag.
i actually dont have any labels. the word itself is a string inside a textbox.
Then you will need to use the Mid$ function to change the "*" you want with the letter you want to show.
thanks..could you possibly give me an example of how i could do that? ive tried it and im doing it wrong...:(
Let's stick to what you're doing... you could learn from your mistakes. Post your code and we'll see it.
ive erased it, but it went something like -
dim MyWord as string
dim LetterPosition as integer
Mid$(MyWord, LetterPosition, 1) = Chr(index + 65)
'all this is under the cmdLetter_click
Try this:VB Code:
Private Sub cmdLetter_click(Index As Integer) Dim MyWord As String Dim LetterPosition As Integer For LetterPosition = 1 To Len(WordToGuess) If Mid$(WordToGuess, LetterPosition, 1) = Chr$(index + 65) Then Mid$(MyWord, LetterPosition, 1) = Chr(index + 65) End If Next LetterPosition End Sub
nope...doesnt seem to want to do anything..
I guessed I should have said this WordToGuess should be s Public variable where you "saved" you want the user to guess