England Forum - UK Forum
 

Go Back   England Forum - UK Forum > Computers and Technology > Developers Forum > Visual Basic Forum

 

 


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-31-2008
Peon
 
Join Date: Apr 2008
Posts: 23
Default Im creating a loop quiz in visual basics express edition 2005 but im stuck?

now if your not sure what i mean when i say loop quiz i mean one question pops up at a time and you click the next button to go on the next one, now ive done my questions and answers but i want to put pictures in it like with each question with a different picture, heres my code so far

Public Class quiz
Dim count, score As Integer
Dim question(10) As String
Dim answer(10) As String

Private Sub quiz_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
question(1) = "2 + 2?"
answer(1) = "4"
question(2) = "4 + 4"
answer(2) = "8"
question(3) = "8 + 8?"
answer(3) = "16"
question(4) = "2 x 2"
answer(4) = "4"
question(5) = "4 x 5"
answer(5) = "20"
question(6) = "5 x 5"
answer(6) = "25"
question(7) = " 2 x 4"
answer(7) = "8"
question(8) = " 3 x 2"
answer(8) = "6"
question(9) = " 4 x 3"
answer(9) = "12"
question(10) = " 3 x 3"
answer(10) = "9"

count = 1
score = 0

Label1.Text = question(1)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If TextBox1.Text = answer(count) Then score = score + 1
count = count + 1
If count > 10 Then
MsgBox("score is " & score.ToString)
End
End If
Label1.Text = question(count)
TextBox1.Text = String.Empty

End Sub
now this is one of my old quizes i was doing for college as part of my course, i can add a picture tool to my form but i dont want the same picture to show up, how can i add different ones
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links

  #2 (permalink)  
Old 05-31-2008
Peon
 
Join Date: May 2008
Posts: 5
Default

Just add a picture box control to your form and add 2 lines of code under comments. You might also want to add code to check if the file exists first or you can pre-load them into your project as a resource, which would be better :P

Public Class Form1
Dim count, score As Integer
Dim question(10) As String
Dim answer(10) As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Set up picture box with first image
'Note this assumes you have 10 images named
'myimage1 to myimage10 in the root folder or where
'ever you want to store them.
Me.PictureBox1.Image = System.Drawing.Image.FromFile("c:\myimage1.bmp")

question(1) = "2 + 2?"
answer(1) = "4"
question(2) = "4 + 4"
answer(2) = "8"
question(3) = "8 + 8?"
answer(3) = "16"
question(4) = "2 x 2"
answer(4) = "4"
question(5) = "4 x 5"
answer(5) = "20"
question(6) = "5 x 5"
answer(6) = "25"
question(7) = " 2 x 4"
answer(7) = "8"
question(8) = " 3 x 2"
answer(8) = "6"
question(9) = " 4 x 3"
answer(9) = "12"
question(10) = " 3 x 3"
answer(10) = "9"

count = 1
score = 0

Label1.Text = question(1)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = answer(count) Then score = score + 1
count = count + 1
If count > 10 Then
MsgBox("score is " & score.ToString)
End
End If
Label1.Text = question(count)

'Update image after you click
Me.PictureBox1.Image = System.Drawing.Image.FromFile("c:\myimage" & count & ".bmp")

TextBox1.Text = String.Empty
End Sub
End Class
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:03 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
Sedo - Buy and Sell Domain Names and Websites project info: englanddebate.co.uk Statistics for project englanddebate.co.uk etracker® web controlling instead of log file analysis

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176