I need help fixing errors

krazykrisi

Member
Joined
Dec 6, 2005
Messages
15
Programming Experience
1-3
I am making a program that imports classes that I have made already. I am getting all of these errors but I don't understand why or how to fix them. Can someone help me? Here is the code for the program..
VB.NET:
Option Strict On
Imports Burgers
Public Class Form1
    Inherits System.Windows.Forms.Form
    Private Sub btnInstantiate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInstantiate.Click
        Dim i As Integer
        Dim strCondiments As String
        If radBaconBurger.Checked Then
            Dim objBurger As New Burger.DoubleBaconBurger(nudBaconSlices.Value)
            Burgers.Ketchup = chkKetchup.Checked
            Burgers.Mustard = chkMustard.Checked
            Burgers.Pickles = chkPickles.Checked
            Burgers.Lettuce = chkLettuce.Checked
            Burgers.Onions = chkOnions.Checked
            MessageBox.Show("Burger class instantiated!", "Burger Builder")
            For i = 1 To Burger.GetCondimentList.Count
                strCondiments &= objBurger.GetCondimentList.Item(i) & ControlChars.NewLine
            Next
            MessageBox.Show(strCondiments, "Condiment List")
        Else
            If radCheeseBurger.Checked Then
                Dim objBurger As New CheeseBurger
                objBurger.Ketchup = chkKetchup.Checked
                objBurger.Mustard = chkMustard.Checked
                objBurger.Pickles = chkPickles.Checked
                objBurger.Lettuce = chkLettuce.Checked
                objBurger.Onions = chkOnions.Checked
                MessageBox.Show("Burger class instantiated!", "Burger Builder")
                For i = 1 To Burger.GetCondimentList.Count
                    strCondiments &= objBurger.GetCondimentList.Item(i) & ControlChars.NewLine
                Next
                MessageBox.Show(strCondiments, "Condiment List")
            End If
        End If
    End Sub
    Private Sub radCheeseBurger_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radCheeseBurger.CheckedChanged
        If radCheeseBurger.Checked Then
            nudBaconSlices.Enabled = False
        Else
            nudBaconSlices.Enabled = True
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
End Class

here are the erros i'm getting
VB.NET:
Type 'Burger.DoubleBaconBurger' is not defined.
'Ketchup' is not a member of 'Burgers'.
 'Mustard' is not a member of 'Burgers'.
'Pickles' is not a member of 'Burgers'.
'Lettuce' is not a member of 'Burgers'.
'Onions' is not a member of 'Burgers'.
Name 'Burger' is not declared.
Type 'CheeseBurger' is not defined.
Name 'Burger' is not declared.

if you need the code for the classes too let me know.
 

krazykrisi

Member
Joined
Dec 6, 2005
Messages
15
Programming Experience
1-3
here is the Burger Class

VB.NET:
Option Strict On
Public Class Burger
    Private colCondimentList As New Collection()
    Private blnKetchup As Boolean
    Private blnMustard As Boolean
    Private blnPickles As Boolean
    Private blnLettuce As Boolean
    Private blnOnions As Boolean
    Public Sub New()
        blnKetchup = False
        blnMustard = False
        blnPickles = False
        blnLettuce = False
        blnOnions = False
    End Sub
    Public Property Ketchup() As Boolean
        Get
            Return blnKetchup
        End Get
        Set(ByVal Value As Boolean)
            blnKetchup = Value
        End Set
    End Property
    Public Property Mustard() As Boolean
        Get
            Return blnMustard
        End Get
        Set(ByVal Value As Boolean)
            blnMustard = Value
        End Set
    End Property
    Public Property Pickles() As Boolean
        Get
            Return blnPickles
        End Get
        Set(ByVal Value As Boolean)
            blnPickles = Value
        End Set
    End Property
    Public Property Lettuce() As Boolean
        Get
            Return blnLettuce
        End Get
        Set(ByVal Value As Boolean)
            blnLettuce = Value
        End Set
    End Property
    Public Property Onions() As Boolean
        Get
            Return blnOnions
        End Get
        Set(ByVal Value As Boolean)
            blnOnions = Value
        End Set
    End Property
    Public Function GetCondimentList() As Collection
        If blnKetchup Then
            colCondimentList.Add("Ketchup")
        End If
        If blnMustard Then
            colCondimentList.Add("Mustard")
        End If
        If blnPickles Then
            colCondimentList.Add("Pickles")
        End If
        If blnLettuce Then
            colCondimentList.Add("Lettuce")
        End If
        If blnOnions Then
            colCondimentList.Add("Onions")
        End If
        Return colCondimentList
    End Function
End Class
 

komrul_alam

Member
Joined
Feb 20, 2006
Messages
6
Programming Experience
1-3
Hi krazykrisi,

Earlier I tried to reply with explanation but I don't know what happened. It's not posted. I can't write it again.
Please replace your if els end if codes with this one and try

If radBaconBurger.Checked Then
Dim objBurger As New Burger
objBurger .Ketchup = chkKetchup.Checked
objBurger .Mustard = chkMustard.Checked
objBurger .Pickles = chkPickles.Checked
objBurger .Lettuce = chkLettuce.Checked
objBurger .Onions = chkOnions.Checked
MessageBox.Show("Burger class instantiated!", "Burger Builder")
For i = 1 To Burger.GetCondimentList.Count
strCondiments &= objBurger.GetCondimentList.Item(i) & ControlChars.NewLine
Next
MessageBox.Show(strCondiments, "Condiment List")
Else
If radCheeseBurger.Checked Then
Dim objBurger As New Burger
objBurger.Ketchup = chkKetchup.Checked
objBurger.Mustard = chkMustard.Checked
objBurger.Pickles = chkPickles.Checked
objBurger.Lettuce = chkLettuce.Checked
objBurger.Onions = chkOnions.Checked
MessageBox.Show("Burger class instantiated!", "Burger Builder")
For i = 1 To objBurger.GetCondimentList.Count
strCondiments &= objBurger.GetCondimentList.Item(i) & ControlChars.NewLine
Next
MessageBox.Show(strCondiments, "Condiment List")
End If
End If

Note : 1. Do u have a class called CheeseBurger ?
2. Aceess class variables only after initializing a class( creating an object and initializing)
3. Don't try to access class members directly by call name unless it's shared.
 

komrul_alam

Member
Joined
Feb 20, 2006
Messages
6
Programming Experience
1-3
Understood DoubleBaconBurger is the datatable holding info. But untill it's not a memeber of Burger Class how can u write something like Dim objBurger As New Burger.DoubleBaconBurger(nudBaconSlices.Value).

That seems to be the root of the problem.
 

komrul_alam

Member
Joined
Feb 20, 2006
Messages
6
Programming Experience
1-3
Follow the following steps.

1. Copy the whole DoubleBaconBurger Class inside Burger Class, ie Burger Class contains DoubleBaconBurger Class.
2.Create an object of Burger Class and initialize it to access DoubleBaconBurger Class
 
Top Bottom