G
Guest
I am at my wits end. VB .net is supposed to be an object oriented language.
But I have tried hack after hack, and I can not get past either "Reference to
a non-shared member requires an object reference.", or "Name <object> is not
declared." or a stack overflow exception. This is simple object oriented
association. I need for objects generated by Form1, Class1, and Class2 to
talk to each other back and forth. Here is how it starts:
Imports System
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Simulation As New Class1
Public CarA As New Class2
Public CarB As New Class2
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Simulation.update_rideList(True, 3)
End Sub
End Class
'Then the other classes:
Public Class Class1
Public Sub New()
MyBase.New()
End Sub
Public Overridable Sub update_rideList(ByVal car As Boolean, ByVal
floor As Integer)
If (car) Then
CarA.rideList.Add(floor)
CarA.test_change(True)
Else
CarB.rideList.Add(floor)
End If
End Sub
End Class
'and
Public Class Class2
Public Sub New()
MyBase.New()
End Sub
Public rideList As New ArrayList
Public Sub test_change(ByVal change As Boolean)
If (change) Then
Label1.BackColor = Label1.BackColor.Green
End If
End Sub
End Class
Please Help??!!!!
But I have tried hack after hack, and I can not get past either "Reference to
a non-shared member requires an object reference.", or "Name <object> is not
declared." or a stack overflow exception. This is simple object oriented
association. I need for objects generated by Form1, Class1, and Class2 to
talk to each other back and forth. Here is how it starts:
Imports System
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Simulation As New Class1
Public CarA As New Class2
Public CarB As New Class2
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Simulation.update_rideList(True, 3)
End Sub
End Class
'Then the other classes:
Public Class Class1
Public Sub New()
MyBase.New()
End Sub
Public Overridable Sub update_rideList(ByVal car As Boolean, ByVal
floor As Integer)
If (car) Then
CarA.rideList.Add(floor)
CarA.test_change(True)
Else
CarB.rideList.Add(floor)
End If
End Sub
End Class
'and
Public Class Class2
Public Sub New()
MyBase.New()
End Sub
Public rideList As New ArrayList
Public Sub test_change(ByVal change As Boolean)
If (change) Then
Label1.BackColor = Label1.BackColor.Green
End If
End Sub
End Class
Please Help??!!!!