|
-
Oct 13th, 2009, 01:41 AM
#1
Thread Starter
New Member
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
-
Oct 13th, 2009, 05:55 AM
#2
Hyperactive Member
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.
Last edited by gonzalioz; Oct 13th, 2009 at 06:06 AM.
-
Oct 16th, 2009, 12:15 AM
#3
Thread Starter
New Member
Re: Make a quiz in visual basic
thanks for that
but i dont get how can i
add new questions?
can u plz help
-
Oct 16th, 2009, 04:01 AM
#4
Thread Starter
New Member
Re: Make a quiz in visual basic
-
Oct 16th, 2009, 07:16 AM
#5
Fanatic Member
-
Oct 16th, 2009, 10:42 PM
#6
Thread Starter
New Member
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 =]
-
Oct 17th, 2009, 11:06 PM
#7
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|