|
-
Jan 10th, 2002, 10:24 AM
#1
Thread Starter
Lively Member
Component's type and numbers at runtime
I have a form with labels, lines, rectangles and images. Total forms aggregates to about 30, with different designs. Now I want know at run time the type and no. of components (lines, labels etc) on a particular form at run time. Please tell me how to know that and how to use its properties. I believe there some collection to do so. Please help.
Eg. A form has label with a caption "SUSI". At run time I want to know that there is a label on my form and I would like to use its properties like top, left, caption etc.
-
Jan 10th, 2002, 10:29 AM
#2
Here is how to tell how many components you have on a form. I'm not sure what you mean by "how to use its properties"
VB Code:
Private Sub Command1_Click()
Dim MyControl As Control
Dim Counter As Integer
Dim NumOfControls As Integer
Dim NumToGo As Integer
Dim Message As String
NumOfControls = 254
For Each MyControl In Me.Controls
Counter = Counter + 1
Next
NumToGo = NumOfControls - Counter
Message = "You have " & Counter & " control names on this form. "
Message = Message & "You have " & NumToGo & " control names left "
Message = Message & "before you crash and burn."
MsgBox Message
End Sub
-
Jan 10th, 2002, 11:40 AM
#3
Thread Starter
Lively Member
Meaning : How to use its properties
Eg. I have a label named label1 with a caption 'USA'. Now at runtime I want to know its caption by writing label.caption. Here caption is the property of the label component.
Thanks for the reply I am testing it and will reply u after 12 hrs
-
Jan 10th, 2002, 12:15 PM
#4
One important thing to remember when it comes to the maximum number of controls on a form is this. The maximum number of controls allowed on a single form depends on the type of controls used and available system resources. However, there is a fixed limit of 254 control names per form. A control array counts only once toward this limit because all the controls in the array share a single control name.
-
Jan 10th, 2002, 12:24 PM
#5
Thread Starter
Lively Member
Components properties
I changed my mind. I am replying u right now.
I have attached a gif file below. This will help u understand what I want. I have a form with 6 components.
Name Type Properties (specific to the component)
----------------------------------------------------------------------------------
Label1 Label Caption = 'First Label'
Font = Regular
Label2 Label Caption = 'Second Label'
Font = Bold
Line1 Line X1 = 360
BorderWidth = 1
Line2 Line X1 = 1440
BorderWidth=2
Image1 Image
Command1 Button
-------------------------------------------------------------------------
Now when the user click the button (command1) he should get the above information in a text format or as a string. You can use msgbox to display the same.
The code that u have replied only counts the no. of componets but I can't access its properties.
-
Jan 10th, 2002, 12:26 PM
#6
-
Jan 10th, 2002, 12:26 PM
#7
Thread Starter
Lively Member
Screenprint
I am attaching the file here. (I forgot about that)
-
Jan 10th, 2002, 12:32 PM
#8
Thread Starter
Lively Member
I hope u can under stand the table. I formated it in the notepad with tab separations. But it seems a bit unformatted when I posted it.
-
Jan 10th, 2002, 12:55 PM
#9
Thread Starter
Lively Member
Please elaborate
ELABORATE : A control array counts only once toward this limit because all the controls in the array share a single control name.
-
Jan 10th, 2002, 01:10 PM
#10
Lets say you have 10 command buttons. These buttons are set up in a control array, and their names are:
cmdSave(0) through cmdSave(9).
These 10 buttons would only count as one control in terms of the number of allowable controls because all 10 buttons have the same name, i.e., cmdSave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|