Control Loop in Order

  • Thread starter Thread starter Paul Ilacqua
  • Start date Start date
P

Paul Ilacqua

How can create a loop to fill a manual calendar IE
For i as integer = 0 to 31
TextBox &i.Text = yadayada ' Where Textboes are named Textbox1,
Textbox2 etc
Next i
 
How can create a loop to fill a manual calendar IE
For i as integer = 0 to 31
TextBox &i.Text = yadayada ' Where Textboes are named Textbox1, Textbox2
etc
Next i

Your loop is going from 0 to 31, yet you say your textboxes are named
TextBox1... Make your loop go from whatever your textboxes are
numbered, I guess...

For idx As Integer = 1 To 31
Dim name As String = String.Format("TextBox{0}", idx)
Dim tb As TextBox = CType(Controls.Find(name, False)(0), TextBox)
tb.Text = idx.ToString()
Next
 
Am 15.05.2010 23:47, schrieb Paul Ilacqua:
How can create a loop to fill a manual calendar IE
For i as integer = 0 to 31
TextBox &i.Text = yadayada ' Where Textboes are named Textbox1,
Textbox2 etc
Next i

Don't they have meaningful names? Anyway, put them into an array
in the Load event. Henceforth, you can access them by index in
the array.
 
Am 15.05.2010 23:47, schrieb Paul Ilacqua:
How can create a loop to fill a manual calendar IE
For i as integer = 0 to 31
TextBox &i.Text = yadayada ' Where Textboes are named Textbox1, Textbox2
etc
Next i

\\\
Dim TextBoxes() As TextBox = {Me.TextBox1, Me.TextBox2, ...}
For Each TextBox As TextBox in TextBoxes
TextBox.Text = ...
Next TextBox
///
 
I ended up with this and it works perfectly... I later shade the filled in
calendar with dated entries from an application. The builtin calendar really
lacks in visual formatting.

Sub PopulateCalendar(ByVal MyDate As Date)

Dim s As String = ""
Dim lbl As Label = Nothing
Call ClearText()

Dim d As New DateTime(MyDate.Year, MyDate.Month, 1)
Dim iDaysInMonth As Short =
CShort(System.DateTime.DaysInMonth(d.Year, d.Month))
Dim iDay As Integer = 1
Dim StartDay As Integer = d.DayOfWeek
StartLabel = "Label" & StartDay + 1
For i As Integer = StartDay + 1 To iDaysInMonth + StartDay
s = "Label" & CStr(i)
lbl = CType(GrpCal.Controls(s), Label)
lbl.Text = CStr(iDay)
iDay = iDay + 1
Next i
End Sub

Thank you for the replies...
 
Back
Top