Results 1 to 3 of 3

Thread: [RESOLVED] Assign New Property to Control

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2010
    Location
    Gold Coast, Australia
    Posts
    43

    Resolved [RESOLVED] Assign New Property to Control

    i currently have a Control Array, and need to give each control a specific name as the control i am using does not have this kind of property.

    At the moment i just made a seperate String Array which holds the values that i want for each control.

    Is it possible to assign a new property to a control so that it may be like this?

    Code:
    Winsock1(1).Username
    (Username is not a current property of Winsock1 control)

    This would make my project run a lot smoother. Any help would be greatly appreciated thank you

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Assign New Property to Control

    Here is one way where you can use Collections to hold the information:
    Code:
    Option Explicit
    
    Dim Username As Collection
    
    Private Sub Command1_Click()
        MsgBox Username(Winsock1.Name)
    End Sub
    
    Private Sub Form_Load()
        Set Username = New Collection
        Username.Add "Matthew", Winsock1.Name
    End Sub
    Not exactly what you want, but something like it. You can use the Index as well:
    Code:
    Option Explicit
    
    Dim Username As Collection
    
    Private Sub Command1_Click()
        MsgBox Username(CStr(Winsock1(0).Index))
    End Sub
    
    Private Sub Form_Load()
        Set Username = New Collection
        Username.Add "Matthew", CStr(Winsock1(0).Index)
    End Sub
    Or you can use the Tag property, place some individual index number and then use that. However remember Tag stores information as a String and Collections make difference with a numeric and string indexes.
    Last edited by Merri; Apr 25th, 2010 at 09:52 PM.

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2010
    Location
    Gold Coast, Australia
    Posts
    43

    Re: Assign New Property to Control

    thank you very much Merri!

    it was just the answer i was looking for

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