2 Replies - 1348 Views - Last Post: 03 November 2012 - 04:36 PM Rate Topic: -----

#1 ImConfused.com   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-October 12

Data Member Not Found

Posted 31 October 2012 - 04:45 AM

Okay so I’m doing a quiz for my project in VB6.

I use three forms, a main menu, the quiz itself and then the high score table. I seem to be having trouble with my quiz form with the code.

I get an error saying data member not found for the .question part. Help?

The error is in the first Questions(0) line

Take a look

Option Explicit

Dim Questions(19) As Frame
Dim i As Integer
Dim Question As String
Dim Option1 As String
Dim Option2 As String
Dim Option3 As String
Dim Answer As Integer
Dim Score As Integer


Private Sub Form_Load()

'Set question Format here

Questions(0).Question = "What feasibility study looks at the cost implications involved with the project?"
Questions(0).Option1 = "Economic"
Questions(0).Option2 = "Technical"
Questions(0).Option3 = "Schedule"
Questions(0).Answer = 1

Questions(1).Question = "The ? contains a full, detailed description of the problem including inputs, processes and outputs."
Questions(1).Option1 = "Project Proposal"
Questions(1).Option2 = "The ORD"
Questions(1).Option3 = "Feasibility Study"
Questions(1).Answer = 2

Questions(2).Question = "What factor might the project team investigate?"
Questions(2).Option1 = "Existence of current software for biometric identification"
Questions(2).Option2 = "Economic feasibility"
Questions(2).Option3 = "Encapsulation"
Questions(2).Answer = 1

Questions(3).Question = "What strategy could be used to manage the project?"
Questions(3).Option1 = "Delegating tasks"
Questions(3).Option2 = "Gannt Chart"
Questions(3).Option3 = "Critical Path Analysis (CPA) could be used to identify all tasks that must be complete and their minimum time length for completion"
Questions(3).Answer = 3

Questions(4).Question = "What is used to record the contents of a variable during manual execution?"
Questions(4).Option1 = "Telling someone else"
Questions(4).Option2 = "Trace Table"
Questions(4).Option3 = "Writing down your findings in note form"
Questions(4).Answer = 2

Questions(5).Question = "Object oriented languages developed because?"
Questions(5).Option1 = "GUI environments cannot be programmes by the constructs of conventional languages"
Questions(5).Option2 = "They wanted to put graphics in the programs"
Questions(5).Option3 = "They didn't like the old programming languages"
Questions(5).Answer = 1

Questions(6).Question = "What is a class?"
Questions(6).Option1 = "A collection of objects each of which have command characteristics"
Questions(6).Option2 = "The binding of data and methods within an object "
Questions(6).Option3 = "Two objects that respond to a message in different ways"
Questions(6).Answer = 1

Questions(7).Question = "What allows new classes to be created by extending existing classes? "
Questions(7).Option1 = "Polymorphism"
Questions(7).Option2 = "Encapsulation"
Questions(7).Option3 = "Inheritance"
Questions(7).Answer = 3

Questions(8).Question = "Why are 1-Dimensional arrays used instead of 2-Dimensional arrays? "
Questions(8).Option1 = "2-Dimensional arrays are complicated"
Questions(8).Option2 = "1-Dimensional arrays are more efficient to sort data stored as numerical then string"
Questions(8).Option3 = "2-Dimensional arrays aren't used a lot"
Questions(8).Answer = 2

Questions(9).Question = "What sort is being described? This is a repeated process that compares numbers and swaps them if the second is smaller until the list is in the correct order"
Questions(9).Option1 = "Selection sort"
Questions(9).Option2 = " Bubble sort"
Questions(9).Option3 = "Simple sort"
Questions(9).Answer = 3

Questions(10).Question = "How does the selection sort work?"
Questions(10).Option1 = "It uses two lists and finds the smallest number by comparing the numbers against each other"
Questions(10).Option2 = "It compares two adjacent items to determine if they are out of order and need exchanged"
Questions(10).Option3 = "Compares adjacent items and if out of order swaps them this repeats until there are no more swaps"
Questions(10).Answer = 1

Questions(11).Question = "What is the underscore character '_' used for in prolog?"
Questions(11).Option1 = "It is used in queries to indicate a variable whose value is not required"
Questions(11).Option2 = " It is used in queries to indicate a required variable"
Questions(11).Option3 = "It can be used for copying the variable in the previous query"
Questions(11).Answer = 1

Questions(12).Question = "Which one of the following is a graphical notation used to describe the structure of software?"
Questions(12).Option1 = "Outline diagram"
Questions(12).Option2 = " Structure chart"
Questions(12).Option3 = "Gannt chart"
Questions(12).Answer = 2

Questions(13).Question = "What item is not included in the Operational Requirements Document?"
Questions(13).Option1 = "Syntactic analysis"
Questions(13).Option2 = "Scope of the system"
Questions(13).Option3 = "Time and details of user training"
Questions(13).Answer = 1

Questions(14).Question = "Who will perform the system investigation?"
Questions(14).Option1 = "Systems analyst"
Questions(14).Option2 = " Project leader"
Questions(14).Option3 = "Consultant"
Questions(14).Answer = 1

Questions(15).Question = "What are Fourth Generation Languages?"
Questions(15).Option1 = " Assembly languages"
Questions(15).Option2 = "Fourth-generation languages are programming languages closer to human languages than typical languages"
Questions(15).Option3 = "Languages used for artificial intelligence and neural networks"
Questions(15).Answer = 2

Questions(16).Question = "Describe one operation that might be used on an object"
Questions(16).Option1 = "Change its appearance"
Questions(16).Option2 = "Move its location"
Questions(16).Option3 = "Add a new member"
Questions(16).Answer = 3

Questions(17).Question = "Describe one advantage of using a heuristic search compared to using an exhaustive search."
Questions(17).Option1 = "It has a suitable evaluation function"
Questions(17).Option2 = "It uses less memory"
Questions(17).Option3 = "It should cut down search time"
Questions(17).Answer = 3

Questions(18).Question = "Describe a situation where maintenance won't have to be carried out on an expert system"
Questions(18).Option1 = "The company broke it recklessly"
Questions(18).Option2 = "Maintenance might be required if the expert system was found to make incorrect predictions"
Questions(18).Option3 = "New features are to be added"
Questions(18).Answer = 1

Questions(19).Question = "What is a default value?"
Questions(19).Option1 = "One that is predetermined by the computer"
Questions(19).Option2 = "A value inherited by subclasses, unless other information is provided"
Questions(19).Option3 = "One that has an error contained"
Questions(19).Answer = 2

End Sub

Private Sub Command1_Click()

i = 0
Score = 0

End Sub
Public Sub AskQuestion()

LblQuestion = Question(Q).Question
Option1.Caption = Question(Q).Option1
Option1.Value = False
Option2.Caption = Question(Q).Option2
Option2.Value = False
Option3.Caption = Question(Q).Option3
Option3.Value = False

End Sub

Private Sub Command2_Click()

Dim Finish As String

Finish = MsgBox("Are you sure you want to exit? All quiz progress will be lost", vbYesNo)
If Finish = vbYes Then
    Load Form1
    Form1.Show vbModal
ElseIf Finish = vbNo Then
End If

End Sub

Private Sub Command3_Click()

If Option1.Value = True And Question(i).Answer = 1 Then
    Score = Score + 50
    Option1.BackColor = vbGreen
ElseIf Option2.Value = True And Question(i).Answer = 2 Then
    Score = Score + 50
    Option2.BackColor = vbGreen
ElseIf Option3.Value = True And Question(i).Answer = 3 Then
    Score = Score + 50
    Option3.BackColor = vbGreen
    Score = Score - 25
End If

i = i + 1
If i = UBound(Question) Then
    MsgBox "You Scored " & Score, vbInformation + vbOKOnly, "Score"
    savescore = MsgBox("Would you like to save your score?, vbyesno")
    If savescore = vbYes Then
        CommonDialogSaveAs.Filter = "Text files{*.txt)|*.txt"
            If CommonDialogSaveAs.FileName <> "" Then
                Open CommonDialogSaveAs.FileName For Output As #1
            End If
    ElseIf savescore = vbNo Then
    End If
End If
End If
End Sub

MOD EDIT: Fixed code tags. The RIGHT way to use code tags:


This post has been edited by JackOfAllTrades: 31 October 2012 - 12:19 PM
Reason for edit:: Fixed code tags

Is This A Good Question/Topic? 0
  • +

Replies To: Data Member Not Found

#2 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: Data Member Not Found

Posted 31 October 2012 - 05:12 AM

You have declared Questions as an array of type Frame.

Question, is not a member of the frame control, which is why your getting the error.
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes   User is offline

  • Lovable Curmudgeon
  • member icon

Reputation: 600
  • View blog
  • Posts: 3,071
  • Joined: 19-May 09

Re: Data Member Not Found

Posted 03 November 2012 - 04:36 PM

What you really ought to do is simply put a label in your frame, and three option buttons, and then keep changing the values of them as you go through the exam. Just load the questions and answers into an array, and keep changing them each time the user hits a "next" button. In the "next" button's click event, put a static integer variable and use it to keep track of the current question.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1