Results 1 to 7 of 7
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cicling label caption... (2000 sr-1)

    In a userform have 4 label label55, label56...label58.
    my code fill a var named TAB with value.
    ho to fill with the value of TAB the caption of the first free caption of label?
    example label55 is filled go to next free caption...ecc.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: cicling label caption... (2000 sr-1)

    I don't understand. What is a "free caption of label" and how is it determined?

    Steve

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: cicling label caption... (2000 sr-1)

    Attached example.
    Free is the caption text of label...

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: cicling label caption... (2000 sr-1)

    Like this?
    TAB is an object name so I made the variable "sTab"...
    I went from 0 to 3 since the controls start at 0 and not 1...

    Steve

    <pre>Option Explicit
    Sub CICLA()
    Dim sTab As String
    Dim i As Integer
    For i = 0 To 3
    If Me.Controls(i).Caption = "" Then
    sTab = Me.Controls(i).Name
    Exit For
    End If
    Next i
    If sTab = "" Then
    MsgBox "There are no free Captions"
    Else
    MsgBox "The control " & sTab & " is Free"
    End If
    End Sub</pre>


  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: cicling label caption... (2000 sr-1)

    PERFECT! that is wath i really want...
    But in userform is present other label and i dont want to use that with your code...
    i think, if i want to intecept only the label from label55 to label58 i modify only the next cicle in:
    For i = 55 To 58
    or not?

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: cicling label caption... (2000 sr-1)

    <P ID="edit" class=small>(Edited by sdckapr on 25-Sep-07 09:27. Added PS)</P>Yes but then you must use the names and not the numbers

    <pre> For i = 55 To 58
    If Me.Controls("Label" & i).Caption = "" Then
    sTab = Me.Controls("Label" & i).Name
    Exit For
    End If
    Next i</pre>


    Steve

    PS or even:
    sTab = "Label" & i

    since you already know the name with the "i" and don't need to look it up again...

  7. #7
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: cicling label caption... (2000 sr-1)

    TKS! .... and tks for expalin code.
    Sal.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •