Hi, I'm new to VB and I am supposed to be writing a program for my instructor using VB 2008. It is sort of like a quiz program. You build the "light bulb" program but instead of names and colors, it consists of two forms. Question 1 with a "next" button and the second form for Question 2 with a "previous" button. I have no idea how to link the two so that when you click "next" it goes to the second page and vice versa. Also when someone clicks on the right answer to the question, the light bulb is supposed to turn on when it's right but stay off if it's wrong. Can someone please help me as I have been trying to figure this out all day. Thanks in advance! :)

On the next button:

Me.Close()
        Me.Dispose()

        Form2.Show()

What is the light bulb? An image? Do you have a "light on" and a "light off" image?

If you do have 2 images, a quick way to get the correct image to show would be to paste the images on top of each other and code on the optCorrectAnswer_CheckedChanged event,

If optCorrectAnswer.Checked = True Then
    imageOn.Visible = True
    imageOff.Visible = False
Else
    imageOn.Visible = False
    imageOff.Visible = True
End If

OK so this is what I have for the first "page".

Public Class VBQuiz

Private Sub LightBulbPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If RadioButtonRadioButton.Checked = True Then
LightBulbPictureBox.Visible = True
LightBulbPictureBox2.Visible = False
Else
LightBulbPictureBox.Visible = False
LightBulbPictureBox2.Visible = True
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'Print the project.

PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'Exit the program.

Me.Close()

End Sub

Private Sub RadioButtonRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonRadioButton.CheckedChanged

End Sub

Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
'Enable the group of radio buttons.
GroupBox1.Enabled = True

End Sub

Private Sub LightBulbPictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LightBulbPictureBox2.Click

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
VBQuiz2.Show()

End Sub
End Class

For the second "page" this is what I have.


<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class VBQuiz2
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(VBQuiz2))
Me.Question1Label = New System.Windows.Forms.Label()
Me.QuestionLabel2 = New System.Windows.Forms.Label()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.TextBoxesRadioButton = New System.Windows.Forms.RadioButton()
Me.ListBoxRadioButton = New System.Windows.Forms.RadioButton()
Me.RadioButtonRadioButton = New System.Windows.Forms.RadioButton()
Me.CheckBoxRadioButton = New System.Windows.Forms.RadioButton()
Me.PreviousButton = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.LightBulbPictureBox2 = New System.Windows.Forms.PictureBox()
Me.LightBulbPictureBox = New System.Windows.Forms.PictureBox()
Me.Button3 = New System.Windows.Forms.Button()
Me.Button4 = New System.Windows.Forms.Button()
Me.PrintForm1 = New Microsoft.VisualBasic.PowerPacks.Printing.PrintForm(Me.components)
Me.GroupBox1.SuspendLayout()
CType(Me.LightBulbPictureBox2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.LightBulbPictureBox, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Question1Label
'
Me.Question1Label.BackColor = System.Drawing.SystemColors.ButtonShadow
Me.Question1Label.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Question1Label.Location = New System.Drawing.Point(12, 9)
Me.Question1Label.Name = "Question1Label"
Me.Question1Label.Size = New System.Drawing.Size(90, 39)
Me.Question1Label.TabIndex = 1
Me.Question1Label.Text = "Question 2"
Me.Question1Label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'QuestionLabel2
'
Me.QuestionLabel2.BackColor = System.Drawing.SystemColors.ButtonShadow
Me.QuestionLabel2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.QuestionLabel2.Location = New System.Drawing.Point(12, 59)
Me.QuestionLabel2.Name = "QuestionLabel2"
Me.QuestionLabel2.Size = New System.Drawing.Size(484, 31)
Me.QuestionLabel2.TabIndex = 2
Me.QuestionLabel2.Text = "Which of the following event runs when a windows application starts?"
Me.QuestionLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.TextBoxesRadioButton)
Me.GroupBox1.Controls.Add(Me.ListBoxRadioButton)
Me.GroupBox1.Controls.Add(Me.RadioButtonRadioButton)
Me.GroupBox1.Controls.Add(Me.CheckBoxRadioButton)
Me.GroupBox1.Location = New System.Drawing.Point(32, 108)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(212, 124)
Me.GroupBox1.TabIndex = 13
Me.GroupBox1.TabStop = False
'
'TextBoxesRadioButton
'
Me.TextBoxesRadioButton.AutoSize = True
Me.TextBoxesRadioButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBoxesRadioButton.Location = New System.Drawing.Point(16, 88)
Me.TextBoxesRadioButton.Name = "TextBoxesRadioButton"
Me.TextBoxesRadioButton.Size = New System.Drawing.Size(176, 17)
Me.TextBoxesRadioButton.TabIndex = 3
Me.TextBoxesRadioButton.Text = "Check Box checked Event"
Me.TextBoxesRadioButton.UseVisualStyleBackColor = True
'
'ListBoxRadioButton
'
Me.ListBoxRadioButton.AutoSize = True
Me.ListBoxRadioButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ListBoxRadioButton.Location = New System.Drawing.Point(16, 65)
Me.ListBoxRadioButton.Name = "ListBoxRadioButton"
Me.ListBoxRadioButton.Size = New System.Drawing.Size(190, 17)
Me.ListBoxRadioButton.TabIndex = 2
Me.ListBoxRadioButton.Text = "Radio Button Checked Event"
Me.ListBoxRadioButton.UseVisualStyleBackColor = True
'
'RadioButtonRadioButton
'
Me.RadioButtonRadioButton.AutoSize = True
Me.RadioButtonRadioButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.RadioButtonRadioButton.Location = New System.Drawing.Point(16, 42)
Me.RadioButtonRadioButton.Name = "RadioButtonRadioButton"
Me.RadioButtonRadioButton.Size = New System.Drawing.Size(121, 17)
Me.RadioButtonRadioButton.TabIndex = 1
Me.RadioButtonRadioButton.Text = "Form Load Event"
Me.RadioButtonRadioButton.UseVisualStyleBackColor = True
'
'CheckBoxRadioButton
'
Me.CheckBoxRadioButton.AutoSize = True
Me.CheckBoxRadioButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBoxRadioButton.Location = New System.Drawing.Point(16, 19)
Me.CheckBoxRadioButton.Name = "CheckBoxRadioButton"
Me.CheckBoxRadioButton.Size = New System.Drawing.Size(131, 17)
Me.CheckBoxRadioButton.TabIndex = 0
Me.CheckBoxRadioButton.Text = "Button Click Event"
Me.CheckBoxRadioButton.UseVisualStyleBackColor = True
'
'PreviousButton
'
Me.PreviousButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center
Me.PreviousButton.Enabled = False
Me.PreviousButton.FlatAppearance.BorderColor = System.Drawing.Color.Silver
Me.PreviousButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.PreviousButton.ForeColor = System.Drawing.SystemColors.Desktop
Me.PreviousButton.Location = New System.Drawing.Point(32, 258)
Me.PreviousButton.Name = "PreviousButton"
Me.PreviousButton.Size = New System.Drawing.Size(92, 43)
Me.PreviousButton.TabIndex = 14
Me.PreviousButton.Text = "Previous"
Me.PreviousButton.UseVisualStyleBackColor = True
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.ForeColor = System.Drawing.SystemColors.GrayText
Me.Button2.Location = New System.Drawing.Point(140, 258)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(92, 43)
Me.Button2.TabIndex = 15
Me.Button2.Text = "Next"
Me.Button2.UseVisualStyleBackColor = True
'
'LightBulbPictureBox2
'
Me.LightBulbPictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
Me.LightBulbPictureBox2.Image = Global.WindowsApplication1.My.Resources.Resources.LightOff
Me.LightBulbPictureBox2.Location = New System.Drawing.Point(312, 108)
Me.LightBulbPictureBox2.Name = "LightBulbPictureBox2"
Me.LightBulbPictureBox2.Size = New System.Drawing.Size(184, 124)
Me.LightBulbPictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.LightBulbPictureBox2.TabIndex = 16
Me.LightBulbPictureBox2.TabStop = False
'
'LightBulbPictureBox
'
Me.LightBulbPictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
Me.LightBulbPictureBox.Image = Global.WindowsApplication1.My.Resources.Resources.LightOn
Me.LightBulbPictureBox.Location = New System.Drawing.Point(312, 108)
Me.LightBulbPictureBox.Name = "LightBulbPictureBox"
Me.LightBulbPictureBox.Size = New System.Drawing.Size(184, 124)
Me.LightBulbPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.LightBulbPictureBox.TabIndex = 17
Me.LightBulbPictureBox.TabStop = False
Me.LightBulbPictureBox.Visible = False
'
'Button3
'
Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button3.Location = New System.Drawing.Point(312, 258)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(92, 43)
Me.Button3.TabIndex = 18
Me.Button3.Text = "Print"
Me.Button3.UseVisualStyleBackColor = True
'
'Button4
'
Me.Button4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button4.Location = New System.Drawing.Point(410, 258)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(92, 43)
Me.Button4.TabIndex = 19
Me.Button4.Text = "Exit"
Me.Button4.UseVisualStyleBackColor = True
'
'PrintForm1
'
Me.PrintForm1.DocumentName = "document"
Me.PrintForm1.Form = Me
Me.PrintForm1.PrintAction = System.Drawing.Printing.PrintAction.PrintToPrinter
Me.PrintForm1.PrinterSettings = CType(resources.GetObject("PrintForm1.PrinterSettings"), System.Drawing.Printing.PrinterSettings)
Me.PrintForm1.PrintFileName = Nothing
'
'VBQuiz2
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(527, 328)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.LightBulbPictureBox2)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.PreviousButton)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.QuestionLabel2)
Me.Controls.Add(Me.Question1Label)
Me.Controls.Add(Me.LightBulbPictureBox)
Me.Name = "VBQuiz2"
Me.Text = "VBQuiz2"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
CType(Me.LightBulbPictureBox2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.LightBulbPictureBox, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub
Friend WithEvents Question1Label As System.Windows.Forms.Label
Friend WithEvents QuestionLabel2 As System.Windows.Forms.Label
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents TextBoxesRadioButton As System.Windows.Forms.RadioButton
Friend WithEvents ListBoxRadioButton As System.Windows.Forms.RadioButton
Friend WithEvents RadioButtonRadioButton As System.Windows.Forms.RadioButton
Friend WithEvents CheckBoxRadioButton As System.Windows.Forms.RadioButton
Friend WithEvents PreviousButton As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents LightBulbPictureBox2 As System.Windows.Forms.PictureBox
Friend WithEvents LightBulbPictureBox As System.Windows.Forms.PictureBox
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'Print the project.

PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()

End Sub
Friend WithEvents PrintForm1 As Microsoft.VisualBasic.PowerPacks.Printing.PrintForm

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'Exit the program.

Me.Close()

End Sub

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

End Sub
End Class


Thanks for your help. I really appreciate it. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.