p0711746
07-07-2009, 08:24 AM
Hi. Im new to visual basic 2008. I am now learning classes and how to make an instance of a class. Below are my codes. I have a problem in which the system says my "Calculator.DateCalc2008()" is not defined. the problem is hilighted in red.
The following is my class code.
Public Class DateCalc2008
Private _startDate As DateTime
Private _endDate As DateTime
Private _span AsInteger
Public Property StartDate() As DateTime
Get
StartDate = _startDate
End Get
Set(ByVal value As DateTime)
_startDate = value
End Set
End Property
Public Property EndDate() As DateTime
Get
EndDate = _endDate
End Get
Set(ByVal value As DateTime)
_endDate = value
End Set
End Property
Public Property Span() AsInteger
Get
Span = _span
End Get
Set(ByVal value AsInteger)
_span = value
End Set
End Property
Public Sub IncreaseDate()
EndDate = StartDate.AddDays(Span)
End Sub
End Class
'This is my object codes. Reference from above.
Public Class Calculator
Private Sub StartDatePicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartDatePicker.ValueChanged
Dim myCalc AsNew Calculator.DateCalc2008()
myCalc.StartDate = StartDatePicker.value
myCalc.Span = 7
myCalc.IncreaseDate()
EndDate.Text = myCalc.EndDate.ToString()
End Sub
End Class
The following is my class code.
Public Class DateCalc2008
Private _startDate As DateTime
Private _endDate As DateTime
Private _span AsInteger
Public Property StartDate() As DateTime
Get
StartDate = _startDate
End Get
Set(ByVal value As DateTime)
_startDate = value
End Set
End Property
Public Property EndDate() As DateTime
Get
EndDate = _endDate
End Get
Set(ByVal value As DateTime)
_endDate = value
End Set
End Property
Public Property Span() AsInteger
Get
Span = _span
End Get
Set(ByVal value AsInteger)
_span = value
End Set
End Property
Public Sub IncreaseDate()
EndDate = StartDate.AddDays(Span)
End Sub
End Class
'This is my object codes. Reference from above.
Public Class Calculator
Private Sub StartDatePicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartDatePicker.ValueChanged
Dim myCalc AsNew Calculator.DateCalc2008()
myCalc.StartDate = StartDatePicker.value
myCalc.Span = 7
myCalc.IncreaseDate()
EndDate.Text = myCalc.EndDate.ToString()
End Sub
End Class