Public Class QuestionsArray
Inherits System.Collections.CollectionBase
Private mywindow As System.Windows.Forms.Form
Public TrueButton As System.Windows.Forms.RadioButton
Public FalseButton As System.Windows.Forms.RadioButton
Public DButton As System.Windows.Forms.RadioButton
Public AnswerGroup As System.Windows.Forms.GroupBox
Public QstNo As System.Windows.Forms.Label
Private Questionno As Integer
Private Answer As String
Sub New(ByVal Questionno1 As Integer, ByVal QSTWIND As System.Windows.Forms.Form)
Questionno = Questionno1
mywindow = QSTWIND
TrueButton = New System.Windows.Forms.RadioButton
FalseButton = New System.Windows.Forms.RadioButton
DButton = New System.Windows.Forms.RadioButton
AnswerGroup = New System.Windows.Forms.GroupBox
QstNo = New System.Windows.Forms.Label
End Sub
Public Function AddNewQuestion(ByVal Questionno As Integer, ByVal toppos As Integer, ByVal leftpos As Integer) As System.Windows.Forms.GroupBox
Dim a As EventArgs
Dim leftst = 10
AnswerGroup.Controls.Add(QstNo)
AnswerGroup.Controls.Add(TrueButton)
AnswerGroup.Controls.Add(FalseButton)
AnswerGroup.Controls.Add(DButton)
Dim ctlwidth As Integer
Dim ctlspacing As Integer
ctlwidth = 50
ctlspacing = 60
QstNo.Top = 15
QstNo.Left = leftst
QstNo.Width = 0.6 * ctlwidth
QstNo.Text = Questionno.ToString() & "."
TrueButton.Top = 10
leftst = leftst 0.6 * ctlspacing
TrueButton.Left = leftst
TrueButton.Width = ctlwidth
TrueButton.Height = 24
TrueButton.Text = "True"
AddHandler TrueButton.CheckedChanged, AddressOf AnswerkeysT
FalseButton.Top = 10
leftst = leftst ctlspacing
FalseButton.Left = leftst
FalseButton.Width = ctlwidth
FalseButton.Height = 24
FalseButton.Text = "False"
AddHandler FalseButton.CheckedChanged, AddressOf AnswerkeysF
DButton.Top = 10
leftst = leftst ctlspacing
DButton.Left = leftst
DButton.Width = 2.5 * ctlwidth
DButton.Height = 24
DButton.Text = "Don't care/Pass"
leftst = leftst 2.7 * ctlwidth
AddHandler DButton.CheckedChanged, AddressOf AnswerkeysD
AnswerGroup.Width = leftst
AnswerGroup.Height = 40
AddNewQuestion = AnswerGroup
End Function
Private Sub AnswerkeysT(ByVal sender As Object, ByVal e As System.EventArgs)
Answer = "True"
End Sub
Private Sub AnswerkeysF(ByVal sender As Object, ByVal e As System.EventArgs)
Answer = "False"
End Sub
Private Sub AnswerkeysD(ByVal sender As Object, ByVal e As System.EventArgs)
Answer = "Do'nt Care"
End Sub
End Class
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
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()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.AutoScroll = True
Me.ClientSize = New System.Drawing.Size(408, 414)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadRadioButtons()
End Sub
Private Sub LoadRadioButtons()
Dim tempgroup As System.Windows.Forms.GroupBox
Dim Thissession(600) As QuestionsArray
Dim i As Integer
Dim topst As Integer
topst = 10
i = 1
For i = 0 To 599
Thissession(i) = New QuestionsArray(i 1, Me)
tempgroup = Thissession(i).AddNewQuestion(i 1, topst, 10)
Me.Controls.Add(tempgroup)
tempgroup.Top = topst
topst = topst 50
tempgroup.Left = 10
Next
End Sub
End Class
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)