PDA

Click to See Complete Forum and Search --> : problem with hangman game


cspenny
Nov 11th, 1999, 06:52 AM
I have a lbl that displays a string"_ _ _" for a word in a hangman game the only problem with the game is that when the letter replaces the "_" it dosen't disapeer it moves to the right. questio is cayou rogram a lbl for write over text or do i need to check something else?

Apollo
Nov 11th, 1999, 09:19 AM
Make a new form, don't name it.
Add a label to it, don't name it.
Add a command button, don't name it.
Add a text box, don't name it.

Go to the command button's code.

Put this in there:

'--------------------------------------------

'Two variables for usage
Dim newletter As String
Dim oldcaption As String

'Assign the label's caption to a variable, simple, huh?
oldcaption = Label1.Caption

'Assign the new letter to use, to a variable
newletter = Mid(Text1.Text, 1, 1)

'Now, rewrite the 1st "_" of the caption, with your
'new letter.
Mid(oldcaption, 1, 1) = newletter

'Display the new word, in the caption of the old label
Label1.Caption = oldcaption

'--------------------------------------------

The code is pretty simple. Hope it helps. If you have any further questions, I can probably answer them. As long as they're about text strings that is.

------------------
"I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

cspenny
Nov 11th, 1999, 10:40 AM
thanks Apollo,
After pulling my hair out I foud out that the problem was in the code(Go Figure). the string was actually adding a "_" every time a letter was placed in it. it just looked like it was moving it over. I'm just learning
you guys are great. thanks!!!!!!