02-28-2005, 04:28 PM
Im making an interface engine and one of the basic things i need is to set all the labels to the same font.I did a loop for each label but i dont think im calling it correctly.
For Each Label In Form1 (instead or form1 put Me?)
Label.Font = "Tahoma" <- the problem line with error "doesnt support this property or method"
02-28-2005, 04:32 PM
If you want to change all of the labels:
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
ctrl.Font = "Tahoma"
02-28-2005, 04:45 PM
How would i refer to the form from a module? (instead of using Me or the form's name)
02-28-2005, 04:58 PM
You would use the form's name... Why can't you do that?
02-28-2005, 05:11 PM
Because this isnt going to be used for one form, Its meant to manage all the forms throughout the project.
02-28-2005, 06:00 PM
Well you could loop through the Forms collection too.
Dim frm As Form, ctl As Control
For Each frm in Forms
For Each ctl in frm.Controls
If TypeOf frm.ctl Is Label Then
frm.ctl.Font = "Tahoma"
03-01-2005, 05:40 AM
Ok, so ive got all that sorted, thanks!
Now i just need to see if the name of each object it loops through has a certain prefix.
ie. itl change all the properties of textboxes, as long as they are using the txt prefix in thier names (like txtPass etc.)
03-01-2005, 05:46 AM
when you are going through the loop, check the first 3 letters of the controls name
If Left$(ctl.Name, 3) = "txt" Then
03-01-2005, 06:22 AM
Great, now how can i make an object on event. like say i clicked command1 it would make a textbox etc etc. (not just make it visible)
03-01-2005, 09:58 AM
Use "Load" command. Like this:Load Textbox1(x) where the "x" is the corresponding index
03-01-2005, 11:23 AM
That doesnt work, it needs it already in the form, which i dont want =(
03-01-2005, 02:56 PM
Ok, maybe i put that wrong.
i need it to be able to make a label / textbox / timer / line / button ( as much as possible ) WITHOUT inserting it into the form , so loadig it via some code then setting the functions?
i dont know if this is possible but i sure hope it is.
any help GREATLY apreciated.
03-01-2005, 03:13 PM
if you are not inserting in a form, why you want to load controls
03-01-2005, 04:06 PM
so that itl only have them if the settings define so.
03-01-2005, 06:20 PM
What? I'm seriously not understanding what you are trying to achieve. Can you please describe what you are trying to do?
03-01-2005, 07:06 PM
So if the settings define so, you want to load and insert into the form?
If that's the case, why don't you create the inital control and hide it. then show that and/or load more if the settings define so and make them visible.
03-02-2005, 09:08 AM
because that makes the form( in vb) messy, and requires more system resources ..
03-02-2005, 10:28 AM
You can use Controls.Add, but it's rarely worth the trouble.
Note in particular Thinker's remarks in that thread.