Results 1 to 3 of 3

Thread: Issues with label array

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Posts
    2

    Issues with label array

    I have an array of labels, which will get information from different arrays, depending on which one is selected. I need to assign one of these sets of arrays to a certain label which is in the array. Below is a quick example of the issue:

    Private Sub Command2_Click()
    Tada Label2, 0
    End Sub

    Private Function Tada(Name As Label, Tes As Integer)
    Name(Tes).Caption = Tes
    End Function

    This will not allow you to enter the line: Name(Tes).Caption = Tes, However, if you enter Form1.Name(Tes).Caption = Tes it will allow you to enter, but still not work.

    If anyone has any suggestions on how to get this to work, i would very much appreciated it

  2. #2

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Posts
    2

    Re: Issues with label array

    This is with using VB6

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Issues with label array

    One of these. The issue you have is that the parameter Name is a label control that should include the index too. It is not a control name; but an actual control. That's what is expected

    1. This way
    Code:
    Private Sub Command2_Click()
    Tada Label2(0), 0
    End Sub
    
    Private Function Tada(Name As Label, Tes As Integer)
    Name.Caption = Tes
    End Function
    2. Or this way
    Code:
    Private Sub Command2_Click()
    Tada "Label2", 0
    End Sub
    
    Private Function Tada(Name As String, Tes As Integer)
    Me.Controls(Name)(Tes).Caption = Tes
    End Function
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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