Results 1 to 10 of 10

Thread: Component's type and numbers at runtime

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66

    Post 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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    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:
    1. Private Sub Command1_Click()
    2. Dim MyControl As Control
    3. Dim Counter As Integer
    4. Dim NumOfControls As Integer
    5. Dim NumToGo As Integer
    6. Dim Message As String
    7. NumOfControls = 254
    8.     For Each MyControl In Me.Controls
    9.         Counter = Counter + 1
    10.     Next
    11.     NumToGo = NumOfControls - Counter
    12.     Message = "You have " & Counter & " control names on this form.   "
    13.     Message = Message & "You have " & NumToGo & " control names left "
    14.     Message = Message & "before you crash and burn."
    15.     MsgBox Message
    16. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66

    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

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66

    Unhappy 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.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Where is the attachment?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66

    Screenprint

    I am attaching the file here. (I forgot about that)

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66
    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.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66

    Arrow Please elaborate

    ELABORATE : A control array counts only once toward this limit because all the controls in the array share a single control name.

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    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
  •  



Click Here to Expand Forum to Full Width