Make a quiz in visual basic
im trying to make a simple quiz in visual basic
all it has is a label
a textbox and two buttons
one of the buttons if for checking if the answer is rite
while the other is to go to the next question
i want to make it so
when the next question button is clicked the label changes to the next question
and the textbox is cleared
and then when i press check it checks the answer
plz help
i have no idea how i can do this
im not very skilled at vb
plz help
Re: Make a quiz in visual basic
Code:
Public Class Form
Private _questions As New List(Of Question)
Private _currentQuestionIndex As Integer = 0
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Make new questions:
Dim newQuestion As Question
newQuestion.text = "It is yellow"
newQuestion.answer = "banana"
_questions.Add(newQuestion)
'Question at startup
Label1.Text = _questions(_currentQuestionIndex).text
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text.Equals(_questions(_currentQuestionIndex).answer) Then
MsgBox("You have answered right")
Else
TextBox1.Text = Nothing
MsgBox("Try again")
End If
End Sub
'Next question button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Label1.Text = _questions(_currentQuestionIndex + 1).text
_currentQuestionIndex += 1
TextBox1.Text = Nothing
End Sub
Structure Question
Dim text As String
Dim answer As String
End Structure
End Class
Here is an example.. It has faults like if you click the button for the next question and there isn't one it will give an error...
But at least you have something to start with.
Edit:
You probaly won't understand all of it so what I would do is follow this tutorial:
http://www.homeandlearn.co.uk/NET/vbNet.html
I learned all the basics from that website. It's very clear and easy to read.
Re: Make a quiz in visual basic
thanks for that
but i dont get how can i
add new questions?
can u plz help
Re: Make a quiz in visual basic
Re: Make a quiz in visual basic
It is great that you have come here for answers, however if you need help with your homework, at least be upfront and say "Please Help with Homework!". Then we can actually help you learn so that when the teacher asks you about your code, you can talk about it intelligently and not get stuck trying to explain something you do not understand.
That being said, I have included some Reading Material on structures that will help you understand what they are and how to use them. Make sure you follow through the link that gonzalioz very graciously posted as well. As he said, that will help you get started.....along with the material your class provides!!! :lol:
Good Luck!
D
Re: Make a quiz in visual basic
its not really homework
im doing a project and yes i have read most of the link
that gonzalioz gave me
there still a few left but i dont think i will have time to read more
since the program is due on friday
also i understand most of the code
jsut some parts i dont get
which i asked bout above
and thanks for the link
ill check it out =]
Re: Make a quiz in visual basic
ok thanks for all the help guys
but i dont think i get the one gonzalioz gave me
but ive thought of a more simpler idea
that works =]
thanks for all the help guys =]
ps if u want to know how i did it
plz ask