Hi everyone. I need a little help with some parts of a word guessing game I'm working on. I have some parts done but unsure about others and could use a little advice. Any help is very much appreciated.Here is the code to give more detail: - Dim GameOver As Boolean
-
Dim NumWords As Integer, ThreeWordList(1000) As String, ThreeWordMeaning(1000) As String
-
Dim R As Integer, WordsLeft(1000) As Integer
-
Dim SecretWord As String, ComputerLetters(3) As String
-
Dim myRandom As New Random
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
Dim sreStreamReader As IO.StreamReader
-
-
'THIS SHOULD BE OK
-
' Declare your strings
-
Dim A As String
-
-
sreStreamReader = IO.File.OpenText("dictionary.txt")
-
NumWords = 0
-
-
'This section of the code should read each line from the file dictionary.txt and
-
'store the word in the array ThreeWordList and store the meaning of each word
-
-
'NOT SURE ABOUT THIS PART
-
Do Until NumWords = 1000
-
NumWords = NumWords + 1
-
-
ThreeWordList(NumWords) = A
-
ThreeWordMeaning(NumWords) = A
-
Loop
-
-
'THIS PART SHOULD BE GOOD
-
'Close the File and Display messages in the label as below
-
-
sreStreamReader.Close()
-
lbldisplay.Visible = True
-
lbldisplay.Text = "Guess my secret 3 letter word"
-
lbldisplay.Text = lbldisplay.Text + ControlChars.NewLine + ControlChars.NewLine + "Press New Game To Start"
-
btnNew.Focus()
-
End Sub
-
-
-
-
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
-
Dim I As Integer
-
-
'THIS SHOULD BE OK
-
'Start new game clear listbox, clear labels and enable buttons - basic preliminaries
-
ListBox1.Items.Clear()
-
ListBox1.Items.Add("Guess" + ControlChars.Tab + ControlChars.Tab + "Number of Letters")
-
-
'THIS SHOULD BE RIGHT
-
'Generate a Random Number which can be from 1 to NumWords in the dictionary which you have computed before
-
-
R = myRandom.Next(0, 1001)
-
-
'I THINK THIS IS OK
-
'Generate a secret word using the random number
-
-
SecretWord = ThreeWordList(Int(Rnd() * NumWords) + 1)
-
-
'NEED HELP WITH THIS PART
-
'Extract each letter of the secret word and store each letter in an array called ComputerLetters
-
' myRandom.Next(1, 7)
-
-
-
-
For I = 1 To NumWords
-
WordsLeft(I) = 1
-
Next I
-
-
-
'THIS PART LOOKS GOOD
-
'Ask the user if they want to play and make the panel visible
-
lbldisplay.Text = vbCrLf + "Type in Your Guess." + ControlChars.NewLine & "Then click the Guess Button."
-
pnlGuess.Visible = True
-
-
-
End Sub
-
-
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
-
' exit current game
-
Me.Close()
-
End Sub
-
-
-
-
Private Sub btnGuess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuess.Click
-
-
Dim L As String, userLetters(3) As String
-
Dim X As Integer, Y As Integer, Z As Integer
-
L = txtGuess.Text
-
-
'THIS SHOULD BE OK
-
'Take the guess of the user and make sure it is 3 characters long
-
If Len(L) <> 3 Then
-
lbldisplay.Text = "Your Guess Must Have 3 Letters."
-
End If
-
-
'THIS SHOULD BE OK
-
'Get letters and make sure they are distinct
-
For X = 1 To 3
-
userLetters(X) = Mid(L, X, 1)
-
Next X
-
-
If userLetters(1) = userLetters(2) Or userLetters(1) = userLetters(3) Or userLetters(2) = userLetters(3) Then
-
lbldisplay.Text = "Your Letters Must Be Different."
-
End If
-
-
-
'NOT SURE ABOUT THIS PART
-
'check if the guess is same as secret word then congratulate the user
-
' if not find how many characters are same and display to user
-
' use a for loop
-
If L = SecretWord Then
-
lbldisplay.Text = "Correct - You Have Won the Game."
-
Else
-
Z = 0
-
For X = 1 To 3
-
For Y = 1 To 3
-
If userLetters(Y) = ComputerLetters(X) Then Z = Z + 1
-
-
Next Y
-
Next X
-
End If
-
-
End Sub
-
-
Private Sub btnGiveUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGiveUp.Click
-
-
'THIS SHOULD BE OK
-
'if the user wants to give up tell them the secretword
-
lbldisplay.Text = "That is My Word -" + ControlChars.NewLine + SecretWord
-
-
End Sub
-
End Class
0 1684 Sign in to post your reply or Sign up for a free account.
Similar topics
by: dnphamus13 |
last post by:
I'm new to this and drowning right now. I would like to put my database
online for viewing. I managed to do the filtering but i need to do
PAGING as the XML doc get bigger. From what i understand...
|
by: riflefire |
last post by:
Hello Everyone,
I am using the new MITE c# text game engine to code up a MUD style game. I need a lot of help as i am new to C#. The reason i need the help is that the engine requires c# scripts to...
|
by: Gasten |
last post by:
Hello.
The last weeks I've been coding a roguelike (you know, like nethack) in
python using the nCurses library. Some week ago I ran into a problem:
When I made the object for messagebar-output, I...
|
by: theronnightstar |
last post by:
I am writing an anagram program for my fiance. Figured it would be an
excellent task to learn from. The way it is supposed to work is it
reads in a word list from a file into a temporary...
|
by: tpgames |
last post by:
I need a code that forces all people's firefox browsers to give them a horizontal scroll bar regardless of what their tool bars and other factors tell the browser to do. I have a crossword puzzle...
|
by: javabeginner123 |
last post by:
i have a java prob, and i have to solve it fast, but i'm just getting to know it, so plz help me solve it with full code completed, thanks so much. the prob is to create a monter fight and there is...
|
by: shinerankin |
last post by:
Hi Guys & Gals:
I have a project with using flash that is updated with an xml file. The developer went belly up and is no longer assisting with anything. I need to write a simple html or php form...
|
by: av3rage |
last post by:
I have never done any programming in my life but I have decided to go into engineering and in doing so we have to take this intro to programming course and I am pretty clueless. I am starting to get...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |