2. Display Form1.vb in design view.
3. List the controls by the Name property and the control names, if any, that are not descriptive.
4. Change the Text property of the form to "Hangman."
5. Change the FormBorderStyle property to Fixed3D.
6. Explain why the form should not be resizable.
7. Change the Font of lblWord to Size 12 Bold.
8. Reposition lblWord so that its left edge is aligned with the left edge of the PictureBox picBody (the box in the center of the form).
9. Add code to the btnExit_Click event procedure to close the form, and exit the application by calling the form's Close method.
10. Add code to the btnNew_Click event procedure to:
•Display "??????? ?????" in lblWord.
HINT: Use the Text property.
•Set the value of the btnGuessL Enabled property to True, for example, btnGuessL.Enabled = True.
•Set the value of the Enabled property for btnGuessW and btnSolve to True.
11. Add code to the btnSolve_Click event procedure to display "BASSETT HOUND" in lblWord.
12. Test your code.
13. List the additional variables you think you will need in the program.
14. Declare a form-level variable named strLetterGuessed as type String.
15. Add code to the btnGuessL_Click event procedure to set the value of strLetterGuessed to the value in txtLetter.
16. Test your code.
17. Declare a form-level variable named strWordGuessed as type String.
18. Add code to the btnGuessW_Click event procedure to set the value of strWordGuessed to the text entered in txtWord.
19. Test your code.
20. Open the file btnNew_Click.doc in your project start folder, and review the flowchart. This flowchart is for the completed btnNew_Click sub procedure. This is how the procedure will work by the end of the project. Why are the decisions shown in the flowchart not necessary at this point?
in #10 you need to select a word from your list, then set lblWord.text = new string("?"c,[your word].length)
Let's actually see about that, shall we?
10. Add code to the btnNew_Click event procedure to:
•Display "??????? ?????" in lblWord.
HINT: Use the Text property.
•Set the value of the btnGuessL Enabled property to True, for example, btnGuessL.Enabled = True.
•Set the value of the Enabled property for btnGuessW and btnSolve to True.
Hmm, don't see anything about selecting from a list there...
The answer at this stage is hard-coded to be "BASSETT HOUND", as you can see from step 11. Someone else on these forums has been following these steps. Seeing these instructions makes certain things very clear.
This is probably the worst way to go about writing a Hangman program that I can think of.
For # 20, Why are the decisions shown in the flowchart not necessary at this point?
Because it's a method of converting an arbitrary string to the '?' equivalent.
[Edit: this is not the complete answer, just a pointer... why is the ability to convert an arbitrary string not necessary at this point?]
A better question:
For # 20, Why are the decisions shown in the flowchart not necessary at any point?
Because it's a stupid method of converting an arbitrary string to the '?' equivalent.
Last edited by Evil_Giraffe; Apr 3rd, 2011 at 07:17 PM.
I am really seriously tempted to start my own "Program a Hangman app" beginners tutorial, focusing on what beginners actually need to know about programming in the OO paradigm with VB, instead of asking them to **** about with the WinForms designer and dump a load of procedural code in code-behind.
I am really seriously tempted to start my own "Program a Hangman app" beginners tutorial, focusing on what beginners actually need to know about programming in the OO paradigm with VB, instead of asking them to **** about with the WinForms designer and dump a load of procedural code in code-behind.
Hmm, don't see anything about selecting from a list there...
The answer at this stage is hard-coded to be "BASSETT HOUND", as you can see from step 11. Someone else on these forums has been following these steps. Seeing these instructions makes certain things very clear.
This is probably the worst way to go about writing a Hangman program that I can think of.
Hi!!
So far, this is what I have done with Part 1:
Public Class frmMain
Dim strLetterGuessed As String
Dim strWordGuessed As String
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Close()
End Sub
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
lblWord.Text = "????????????"
End Sub
Private Sub btnSolve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSolve.Click
lblWord.Text = "BASSETT HOUND"
End Sub
Private Sub btnGuessL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuessL.Click
txtLetter.Text = strLetterGuessed
End Sub
Private Sub btnGuessW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuessW.Click
txtWord.Text = strWordGuessed
End Sub
End Class
However, my professor said that I needed a few things. For instance, 1) btnNew_Click - needs the code to enable the objects mentioned in step 10. This is objectName.enabled = true, just use the name of the correct object mentioned 2) Your variable assignments need too be swapped . txtWord.Text = strWordGuessed should be strWordGuessed = txtWord.Text this goes for the other one as well.
Can you please tell me what is exactly that I did wrong and what to correct? I'll appreciate your help. Thanks!
Can you please tell me what is exactly that I did wrong and what to correct? I'll appreciate your help. Thanks!
Your professor has already done this:
Originally Posted by dreyes
1) btnNew_Click - needs the code to enable the objects mentioned in step 10. This is objectName.enabled = true, just use the name of the correct object mentioned
Step 10 says:
10. Add code to the btnNew_Click event procedure to:
•Display "??????? ?????" in lblWord.
HINT: Use the Text property.
•Set the value of the btnGuessL Enabled property to True, for example, btnGuessL.Enabled = True.
•Set the value of the Enabled property for btnGuessW and btnSolve to True.
(Emphasis mine)
Originally Posted by dreyes
2) Your variable assignments need too be swapped . txtWord.Text = strWordGuessed should be strWordGuessed = txtWord.Text this goes for the other one as well.
He's referring to these two subs:
vbnet Code:
Private Sub btnGuessL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuessL.Click
txtLetter.Text = strLetterGuessed
End Sub
Private Sub btnGuessW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuessW.Click
txtWord.Text = strWordGuessed
End Sub
These subs take the contents of txtLetter and txtWord respectively as inputs. What you need to do is assign the value of the Text property of the textboxes to the strLetterGuessed / strWordGuesssed variables. What is your code doing instead?
Can you please tell me what is exactly that I did wrong and what to correct? I'll appreciate your help. Thanks!
No, telling you exactly what you've done wrong and what to correct won't be of any use to you. You'll appreciate it more if we give you just enough assistance to solve it yourself.