Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Structure Quiz
- Dim questionID As Integer
- Dim question As String
- Dim answer As String
- End Structure
- Function BasicHash(questionID, recordLength)
- Return (((1 + (questionID Mod recordLength)) ^ 2) ^ 0.5)
- End Function
- Sub Main()
- Dim isQuizComplete As Boolean
- Dim quizQuestion As Quiz
- Dim recordLen As Integer = Len(quizQuestion)
- FileOpen(1, "C:\Users\tfqsy\OneDrive\Desktop\textfile.txt",
- OpenMode.Random, OpenAccess.Write, RecordLength:=recordLen)
- Do
- Console.Write("Enter the question: ")
- quizQuestion.question = Console.ReadLine
- quizQuestion.questionID = quizQuestion.question.GetHashCode()
- Console.Write("Enter the answer: ")
- quizQuestion.answer = Console.ReadLine
- FilePutObject(1, quizQuestion, BasicHash(quizQuestion.questionID, recordLen))
- Console.Write("Are you done adding questions? (Y/N): ")
- isQuizComplete = Console.ReadLine = "Y"
- Loop Until isQuizComplete
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement