Millkind
asked on
Object reference not set to an instance of an object.
Why is Me.Controls("d" & currentlabel).Text = x saying that "Object reference not set to an instance of an object" How do i fix it?
Dim currentmonth As Integer = DatePart(DateInterval.Month, dtpselector.Value)
Dim currentyear As Integer = DatePart(DateInterval.Year, dtpselector.Value)
Dim previousmonth As Integer = DatePart(DateInterval.Month, DateAdd(DateInterval.Month, -1, dtpselector.Value))
Dim previousyear As Integer = DatePart(DateInterval.Year, DateAdd(DateInterval.Month, -1, dtpselector.Value))
Dim nextmonth As Integer = DatePart(DateInterval.Month, DateAdd(DateInterval.Month, 1, dtpselector.Value))
Dim nextyear As Integer = DatePart(DateInterval.Year, DateAdd(DateInterval.Month, 1, dtpselector.Value))
Dim blankstofill As Integer = DatePart(DateInterval.Weekday, dtpselector.Value) - 1
Dim currentenddate As Integer = Date.DaysInMonth(currentyear, currentmonth)
Dim previousenddate As Integer = Date.DaysInMonth(previousyear, previousmonth)
Dim currentlabel As Integer = 1
'fill previous month data
For x As Integer = blankstofill - previousenddate To previousenddate
Me.Controls("d" & currentlabel).Text = x
currentlabel += 1
Next
'fill current month data with no previous month data
For x As Integer = 1 To currentenddate
Me.Controls("d" & currentlabel).Text = x
currentlabel += 1
Next
''fill next month data
For x As Integer = 1 To 42 - blankstofill - currentenddate
Me.Controls("d" & currentlabel).Text = x
currentlabel += 1
Next
Do you have a label named "d1"?
ASKER
Yes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wonderful explanation. I was using a tabcontrol and needed to change me to the tap page name. Thanks so much.