Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
|
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2008, 12:34 AM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Applying Object and components

this solution will accept 5 question either true or false or multiple choice, then will print the ouput to a file
so is one textbox for the question called txtq, and four for the snswers called txta1,txta2, txta3, txa4
three buttons one called BtnAddTrueFalse, BtnMultiple, and the other BtnPrint.
New questions will be stored in an array of type CQuestion.Each record will be instantiated as either CTrueFalse or CMultiple.To print the file you will loop through the array.
with the help of my book i came out with this code.. but appear not to be working.
can you check the code for the BtnAddTrueFalse and AddMultiple and print

Here is my code..

Public Class CMultiple
    Inherits CQuestion
    Private m1 As String
    Private m2 As String
    Private m3 As String
    Private m4 As String



    Public Sub New(ByVal qnum As Int16, ByVal question As String, ByVal a1 As String, ByVal a2 As String, ByVal a3 As String, ByVal a4 As String)
        MyBase.mQuestionNumber = qnum
        MyBase.mquestion = question
        m1 = a1
        m2 = a2
        m3 = a3
        m4 = a4
    End Sub
    Public Overrides Sub PrintQuestion(ByRef test As String)

    End Sub
End Class

---------------------------------

Public Class CTrueFalse
    Inherits CQuestion
    Public Sub New(ByVal qnum As Int16, ByVal question As String)
        MyBase.mQuestionNumber = qnum
        MyBase.mquestion = question
    End Sub
    Public Overrides Sub PrintQuestion(ByRef test As String)

    End Sub
End Class

---------------------------------------------------

Public MustInherit Class CQuestion
    Protected mQuestionNumber As Int16
    Protected mquestion As String
    Public MustOverride Sub PrintQuestion(ByRef test As String)

End Class
------------------------------------------------

Public Class frmMain
    Private arQ(4) As CQuestion
    Private test As String
    Private Sub frMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        test = "test"
        test &= vbNewLine & vbNewLine
    End Sub

    Private Sub BtnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
        Dim qnum As Int16
        If qnum < 5 Then



            arQ(qnum) = New CTrueFalse(qnum + 1, TxtQuestion.Text)

            qnum += 1

        End If



    End Sub

    Private Sub BtnMultiple_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnMultiple.Click
        Dim qnum As Int16

        arQ(qnum) = New CMultiple(qnum + 1, TxtQuestion.Text, TxtA.Text, TxtB.Text, TxtC.Text, TxtD.Text)


    End Sub

    Private Sub BtnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnPrint.Click





        Dim intX, intY As Integer

        intY = arQ.Length

        For intX = 0 To (intY - 1)

            If arQ(intX) IsNot Nothing Then

                arQ(intX).PrintQuestion(test)

            End If

        Next
        MsgBox(test)
    End Sub
End Class






Similar Threads
Thread Thread Starter Forum Replies Last Post
Applying membership through coding ayyub123 ASP.NET 2.0 Basics 0 May 28th, 2007 12:49 AM
Applying discount blkskullwork Javascript 1 January 11th, 2007 05:14 PM
Applying CSS to tables andyhague CSS Cascading Style Sheets 4 April 5th, 2006 05:30 AM
Applying a template with subreport nat246 Crystal Reports 0 December 12th, 2005 02:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.