Log in

View Full Version : New to VB. Help needed.



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

Tommy
07-10-2009, 11:09 AM
I would start with this. The Class Calculator has a class DataCalc2008 defined as myCalc.
Dim myCalc As New DateCalc2008
I don't see where EndDate has a Text property