PC Review


Reply
Thread Tools Rate Thread

Control Loop in Order

 
 
Paul Ilacqua
Guest
Posts: n/a
 
      15th May 2010
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

 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      15th May 2010
On 5/15/2010 5:47 PM, Paul Ilacqua wrote:
> 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


--
Mike
 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      15th May 2010
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.



--
Armin
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th May 2010
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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
 
Reply With Quote
 
Paul Ilacqua
Guest
Posts: n/a
 
      16th May 2010
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...


"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
> ///
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reverse order on FOR loop? Eric Microsoft Excel Programming 1 9th Apr 2010 12:43 AM
Reversing the order of a For-Each loop action? Henry Microsoft Excel Programming 8 11th Jun 2009 07:46 PM
Order of For Each Loop through controls in a frame? Aviashn Microsoft Excel Programming 9 19th Feb 2008 11:58 PM
Order of controls in For Each Loop RB Smissaert Microsoft Excel Programming 4 23rd Oct 2005 06:54 PM
Nested loop order? jclark419 Microsoft Excel Programming 2 29th Jul 2005 07:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:22 PM.