Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Randomize()
' get the data from text file
' This program reads 5 data Items
' inFile opens the notepad file
inFile = IO.File.OpenText("My.Resources.Resource1.words_txt")
'this function loops around until there is no more data
Do Until inFile.Peek = -1
X = X + 1
'Word(1) stores the first word; Word(2) stores the second word and so forth
Word(X) = inFile.ReadLine
Loop
'you must close the file
inFile.Close()
End Sub
Private Sub btnWord_Click(sender As Object, e As EventArgs) Handles btnWord.Click
y = Int(Rnd() * 10) + 1
lblWord.Text = Word(y)
End Sub
No comments:
Post a Comment