Volte
12-21-2001, 04:31 PM
I got this idea from that thing I made in the Tutors Corner to celebrate my 800th post (the Useful Tips and Tricks tutor).
OK, everyone can contribute any time saving tricks or little known facts about VB: the IDE, coding, etc... anything! So, first go read my thing in Tutors Corner.
Anyway, I'll start:
---------------------------------
Did you know that you can access a control by name using a string? Sort of like CallByName for procedures.
<pre>Me.Controls("Label1").Caption = "Test!"</pre> will do exactly what it would normally. You can easily use a loop to fill a bunch of controls. This also allows you to make 'hacks' of two or three dimensional control arrays. They wouldn't be all that easy to create in the first place, but after that, the coding would be easier. For example, if you had textboxes called txtField1_1 through txtField5_8, you could use this method to access them easily.<pre>Dim iFirst As Integer, iSecond As Integer
For iFirst = 1 To 5
For iSecond = 1 To 8
Me.Controls("txtField" & iFirst & "_" & iSecond).Text = "Hello!!!!"
Next iSecond
Next iFirst</pre>
Anyway, now it's your turn. images/icons/wink.gif
OK, everyone can contribute any time saving tricks or little known facts about VB: the IDE, coding, etc... anything! So, first go read my thing in Tutors Corner.
Anyway, I'll start:
---------------------------------
Did you know that you can access a control by name using a string? Sort of like CallByName for procedures.
<pre>Me.Controls("Label1").Caption = "Test!"</pre> will do exactly what it would normally. You can easily use a loop to fill a bunch of controls. This also allows you to make 'hacks' of two or three dimensional control arrays. They wouldn't be all that easy to create in the first place, but after that, the coding would be easier. For example, if you had textboxes called txtField1_1 through txtField5_8, you could use this method to access them easily.<pre>Dim iFirst As Integer, iSecond As Integer
For iFirst = 1 To 5
For iSecond = 1 To 8
Me.Controls("txtField" & iFirst & "_" & iSecond).Text = "Hello!!!!"
Next iSecond
Next iFirst</pre>
Anyway, now it's your turn. images/icons/wink.gif