November 19th, 2013, 03:45 PM
My Logic is well mess need help with System.IO
I really would appericate if you can either point me to the right direction or give me a example of how it could be done.
As part of my University project I am writting a program that basically helps people with spelling the objective are
App will speak out the word and user will type the word if match found then you get a point if not then you get a point for getting it wrong so at the end of spelling list you will know how many you got right and how many you got wrong.
the problem is my code a does not generate random word from my list of spelling and B it just runs from begaining of the file to the end of the file with out giving the user the option to enter a new word after the app has spoken .
here is my code
' Declare a variable for system.IO as streamReader
Dim ObjReader As New System.IO.StreamReader("C:\Users\waheedrafiq\Dropbox\University BCU\Visual Basic ICT\Basic_AI\EnglishSpellingABC\englishspelling.txt")
Dim Count As Integer
Dim CountWrongAnswer As Integer
Dim sLine As String = "" ' Declare sLine as string variable to be use in the loop
Dim userInput As String ' declare UserInput as string to be use to store user value.
Count = 0
CountWrongAnswer = 0
Do While ObjReader.EndOfStream = False ' Do while we have not reach end of file.
sLine = ObjReader.ReadLine() ' Read from file and store value to sLine
speakWord.Speak(sLine) ' Speak the value store in sLine
sLine.ToUpper().Trim() ' convert sLine value to Uppercase remove any spaces
' userInput = InputBox("Enter correct spelling" & vbOKOnly)
userInput = txtUserInput.Text ' Store value from textbox to userinput variable
userInput.ToUpper().Trim() ' covert userInput value to uppercase and remove any spaces
If sLine.ToUpper.Trim = userInput.ToUpper.Trim Then
speakWord.Speak("Well done that was the correct answer")
Count += 1
lblScore.Text = CStr(Val(Count.ToString))
ElseIf ObjReader.EndOfStream = True Then
speakWord.Speak("Spelling test has ended well done " & "You have Scored" & Count & "Out of " & CountWrongAnswer)
' Exit Do
CountWrongAnswer += 1
lblWrongScore.Text = CStr(Val(CountWrongAnswer.ToString))
any support will be much appreciated
Last edited by GremlinSA; November 20th, 2013 at 12:48 AM.
Reason: added code tags...
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!