Hi, this is my first post in this site. I am having trouble with a hangman program that I've writen. I have got allmost every thing working fine, but I am having trouble ensuring that a word is not used twice. The way in which, my program works is that I have a record array that one past holds words called "word"(filled from a file) and another part stores if that word has been used called "used". I should not need to write to an output file as its only required that the word not be used more than one in one istance of the program. Also when, the user has used all words in the array "words" the program is to display a mesage delcaring this.
Here is sections of my code ( I deleted what is not realed to the problem, to shorten / make the program easier to read). I would apreacete any help:
Global variables :
Const maxwords = 100 ' set the maximum amount of words that can be stored to 100
Structure tthemecont 'declare a record blueprint
Dim words As String ' this array will hold words to guess from a file
Dim used As Boolean ' this array will be used to detrmin if a word has all readt been used
End Structure
Dim generaltheme As String 'these variables are used to store the name of the file to be read from and also used to populate a combo box
Dim userword As String 'this is stored and updated as the user quesses letters
Dim word As String ' This stores the word that has been selected to be guessed
Dim theme(maxwords) As tthemecont 'array of records
Dim lifes As Integer ' this varible will store the amount of guesses the user has to guess the word
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer ' i is a loop control variable
Randomize() ' Initalize the random generator
For i = 0 To maxwords ' loop's through all locations in an array at sets their value to false
theme(i).used = False
Next
FileOpen(1, generaltheme, OpenMode.Input) ' reads words from a file a stores them in an array
i = 0
Do While Not EOF(1) ' Add each line from the file to an arrray
theme(i).words = LineInput(1)
i = i + 1
Loop
FileClose(1) 'Close the file
End Sub
Private Sub Btnstart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnstart.Click
Dim i As Integer ' i is a loop control variable
Dim randomnumber As Integer ' this variable will store a random number that is generated
randomnumber = Int(Rnd() * 10) ' this is used to generate a random number
If theme(randomnumber).used = False Then ' Used to determin if a word has been not used all ready
word = theme(randomnumber).words 'adds the word at the current random location in an array into a variable called word
theme(randomnumber).used = True ' changes the uses vaule to true at the current random location in a array
End If