| | |
Simple Hangman Game
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2008
Posts: 16
Reputation:
Solved Threads: 0
have found a really interesting ,but simple hangman game on the net but i am really confused to how it actually works ,i would like to re-create it for myself but first i would need to understand it.it seems to use complicated code ,but there is much of it and the creator hasnt labeled all the pieces of code so it doesnt help.If u cud help me to disect the code then id be grateful .
The most confusing part of the code is how the creator actually got the letter and characters to appear like they do.Also would you be able to explain "CheckChar" ,"String$","UCase" , "Call" and "QuestionHandler"
http://www.sendspace.com/file/a4wye8
thanx
The most confusing part of the code is how the creator actually got the letter and characters to appear like they do.Also would you be able to explain "CheckChar" ,"String$","UCase" , "Call" and "QuestionHandler"
http://www.sendspace.com/file/a4wye8
thanx
Call keyword is used to call any procedure by its name but its purely optional
like u can write
or just
Regards
Shaik Akthar
like u can write
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Call txtGuess_Change
or just
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
txtGuess_Change
Regards
Shaik Akthar
•
•
Join Date: Aug 2008
Posts: 16
Reputation:
Solved Threads: 0
can someone please explain "ChkChar"???I will rep.
ALSO
would someone please be able to tell me how to make code for the game so that it counts the number of correct guesses,for this game.I know that a label will need to be used etc.
http://www.sendspace.com/file/a4wye8
and for
Hangman.zip http://www.daniweb.com/forums/attach...1&d=1218656270
ALSO
would someone please be able to tell me how to make code for the game so that it counts the number of correct guesses,for this game.I know that a label will need to be used etc.
http://www.sendspace.com/file/a4wye8
and for
Hangman.zip http://www.daniweb.com/forums/attach...1&d=1218656270
'Posi ' variable is used to track as when to move to the next line to print the body or arms or legs of the hangman.
when 'Posi' is 2 (i.e) when 2nd wrong guess is made, the '|' character must go to next line. hence 'Posi' is checked and if it is 2 a new line (vbCrLf) is appended.
Similarly when 'Posi' is 3 again we have to move to the next line to start the hands.
and when 'Posi' is 6 we have to move to the next line to start the legs.
Finally when 'Posi' is 8 (i.e) the hangmans last leg is to be displayed, then will be the end of the guesses because man hanging is complete with the last leg.
This is the point where the user is failed to guess the correct answer.
CheckChar function is used to check if the character typed in the guess box is present in the string pertaining to the 'intQuestionNumber'th value in the array. if not the guess is wrong. hence clear the Guess TextBox and go for the next try. If all tries are over i.e. 'Posi' is reached 8 as said above the game is lost. if before the 'Posi' reaches 8 the string the Question label with '_' matches the 'intQuestionNumber'th value in the array, the game is won.
Also u can count the wins and losses also.
Take 2 global integer variables and make then equal to 0 during form load.
One for Win Count and one for Lost Count.
The sum of these two will be Played Count.
Check out the attachment i have modified.
Some other suggestions
================
1. Change the words now and then
or
2. increase the number of words
or
3. put the strings in a text file and read the values from them
No 3. is better because u need not compile ur project again and again whenever u change the words.
Regards
Shaik Akthar
when 'Posi' is 2 (i.e) when 2nd wrong guess is made, the '|' character must go to next line. hence 'Posi' is checked and if it is 2 a new line (vbCrLf) is appended.
Similarly when 'Posi' is 3 again we have to move to the next line to start the hands.
and when 'Posi' is 6 we have to move to the next line to start the legs.
Finally when 'Posi' is 8 (i.e) the hangmans last leg is to be displayed, then will be the end of the guesses because man hanging is complete with the last leg.
This is the point where the user is failed to guess the correct answer.
CheckChar function is used to check if the character typed in the guess box is present in the string pertaining to the 'intQuestionNumber'th value in the array. if not the guess is wrong. hence clear the Guess TextBox and go for the next try. If all tries are over i.e. 'Posi' is reached 8 as said above the game is lost. if before the 'Posi' reaches 8 the string the Question label with '_' matches the 'intQuestionNumber'th value in the array, the game is won.
Also u can count the wins and losses also.
Take 2 global integer variables and make then equal to 0 during form load.
One for Win Count and one for Lost Count.
The sum of these two will be Played Count.
Check out the attachment i have modified.
Some other suggestions
================
1. Change the words now and then
or
2. increase the number of words
or
3. put the strings in a text file and read the values from them
No 3. is better because u need not compile ur project again and again whenever u change the words.
Regards
Shaik Akthar
![]() |
Similar Threads
- Projects for the Beginner (Python)
- hangman game in C++ (C++)
- Help with hangman tutorial. (C++)
- C++ Programming issue (C++)
- Having Some Trouble with Methods (Java)
- reading(printing to screen) program (Python)
- Code Confusion (C#)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: inserting Serial No in Report
- Next Thread: Data grid addition problem?
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





