Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WinForms - object access
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Object Oriented Programming
Title:
WinForms - object access
Environment versions
Environment:
VB 8.0
Miscellaneous
Thread ID:
01405232
Message ID:
01405232
Views:
103
Hi All,

How do I have to declare a textbox objects on a form in order to modify it within a function which gets the object name from evaluating a condition?

As a result I would like to change the background color of an existing object.
Private Sub CheckForHolidaySeason(ByVal TodayDate As Date)

        Dim i As Integer = 1
        Dim wkNumber As Integer = 1
        Dim dDate As Date = TodayDate
        Dim objName As New TextBox

        While i <= 52
            'display current values
            'MsgBox(i)
            'MsgBox(wkNumber)
            'MsgBox(dDate)

'check if dDate falls into the Holiday period (wks: 48,49,50,51,52,53)
            If DatePart(DateInterval.WeekOfYear, dDate) = 48 _
                Or DatePart(DateInterval.WeekOfYear, dDate) = 49 _
                Or DatePart(DateInterval.WeekOfYear, dDate) = 50 _
                Or DatePart(DateInterval.WeekOfYear, dDate) = 51 _
                Or DatePart(DateInterval.WeekOfYear, dDate) = 52 _
                Or DatePart(DateInterval.WeekOfYear, dDate) = 53 Then

                'define object name
                objName.Name = "txtW" & Trim(wkNumber.ToString)
                objName.BackColor = Color.Green

            End If

            'increase variables
            dDate = dDate.AddDays(7)
            wkNumber += 1
            i += 1

        End While
    End Sub
Thank you,
Daniel
Next
Reply
Map
View

Click here to load this message in the networking platform