• We just launched and are currently in beta. Join us as we build and grow the community.

How to Create a Local Revision Tool in Visual Basic

jenny399

Crypto Payment Processor
J Rep
0
0
0
Rep
0
J Vouches
0
0
0
Vouches
0
Posts
173
Likes
40
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 100 XP
Introduction:
Welcome to my tutorial on how to create a Revision Tool program in Visual Basic.

Steps of Creation:
Step 1:

First we need to create a form with...

button1 - add a new question and answer
textbox1 - contain a new question
textbox2 - contain a new answer
textbox3 - contain answer to current question
button2 - begin revision
button3 - check answer
label1 - contain current question.

We also want to create a few variables, they are all self explanatory.

  1. Dim

    question As

    New

    List(Of String

    )
  2. Dim

    answers As

    New

    List(Of String

    )
  3. Dim

    curPos As

    Integer

    = -1
  4. Dim

    rand As

    New

    Random

Step 2:
Next we want to create a couple of custom functions. One will simply randomly select the next question to test the user on. The other will check the answer.

  1. Private

    Function

    checkAnswer()
  2. If

    (TextBox3.Text.ToLower() = answers(curPos).ToLower()) Then
  3. MsgBox("Correct!"

    )
  4. Else

    : MsgBox("Wrong! The right answer is: "

    & answers(curPos))
  5. End

    If
  6. End

    Function
  7. Private

    Function

    setNewQuestion()
  8. Dim

    r As

    Integer

    = curPos
  9. Do

    Until

    Not

    r = curPos
  10. r = rand.next

    (question.Count())
  11. Loop
  12. curPos = r
  13. Label1.Text = question(curPos)
  14. End

    Function

Step 3:
For the button1 click event action we want to add the new question and answer to our lists...

  1. question.Add(TextBox1.Text)
  2. answers.Add(TextBox2.Text)

Step 4:
The button1 click event action will begin the revision which will lock our add new question and answer controls and select the first question using our custom function setNewQuestion.

  1. If

    (question.Count() > 0) Then
  2. TextBox1.Enabled = False
  3. TextBox2.Enabled = False
  4. TextBox3.Enabled = True
  5. Button3.Enabled = True
  6. Button1.Enabled = False
  7. Button2.Enabled = False
  8. setNewQuestion()
  9. End

    If

Step 5:
Finally, the button3 click event action will check the given answer to the current question and select a new question to test next.

  1. checkAnswer()
  2. setNewQuestion()

Project Complete!
Below is the full source code and download to the project files.

  1. Public

    Class Form1
  2. Dim

    question As

    New

    List(Of String

    )
  3. Dim

    answers As

    New

    List(Of String

    )
  4. Dim

    curPos As

    Integer

    = -1
  5. Dim

    rand As

    New

    Random
  6. Private

    Sub

    Button1_Click(sender As

    Object

    , e As

    EventArgs) Handles Button1.Click
  7. question.Add(TextBox1.Text)
  8. answers.Add(TextBox2.Text)
  9. End

    Sub
  10. Private

    Function

    checkAnswer()
  11. If

    (TextBox3.Text.ToLower() = answers(curPos).ToLower()) Then
  12. MsgBox("Correct!"

    )
  13. Else

    : MsgBox("Wrong! The right answer is: "

    & answers(curPos))
  14. End

    If
  15. End

    Function
  16. Private

    Function

    setNewQuestion()
  17. Dim

    r As

    Integer

    = curPos
  18. Do

    Until

    Not

    r = curPos
  19. r = rand.next

    (question.Count())
  20. Loop
  21. curPos = r
  22. Label1.Text = question(curPos)
  23. End

    Function

  24. Private

    Sub

    Button2_Click(sender As

    Object

    , e As

    EventArgs) Handles Button2.Click
  25. If

    (question.Count() > 0) Then
  26. TextBox1.Enabled = False
  27. TextBox2.Enabled = False
  28. TextBox3.Enabled = True
  29. Button3.Enabled = True
  30. Button1.Enabled = False
  31. Button2.Enabled = False
  32. setNewQuestion()
  33. End

    If
  34. End

    Sub

  35. Private

    Sub

    Button3_Click(sender As

    Object

    , e As

    EventArgs) Handles Button3.Click
  36. checkAnswer()
  37. setNewQuestion()
  38. End

    Sub
  39. End

    Class

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

330,760

330,768

Top