Results 1 to 4 of 4

Thread: [RESOLVED] [Help]Adding a Variable to a Control.

  1. #1

    Thread Starter
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Resolved [RESOLVED] [Help]Adding a Variable to a Control.

    I'm trying to add a varible to a control, so I can reference the Variable with the Controls name. I would like to set the variable how you would set a regular Integer. This is an example of what I mean:
    Code:
    Messagebox.Show("The ID of Button1 is " & button1.ID & ".")
    
    Result:
    The ID of Button1 is 1.
    If someone could tell me if this is possible or not. I would like to think it is however.

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: [Help]Adding a Variable to a Control.

    I don't think you can. I don't think you can make a variable part of the control. Why not just set a global variable and call it when appropriate?
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [Help]Adding a Variable to a Control.

    you can by inheriting the control, then adding all the properties you want to it.... but there might be easier ways as well... but it depends on what exactly you are trying to accomplish. If all you want is some kind of ID number that is fairly arbitrary, look at using the .Tag property.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Resolved Re: [Help]Adding a Variable to a Control.

    Thank you techgnome. I did a simple Search on "inherit" and found this thread. So using the code provided, I've managed to do EXACTLY what I was looking for.

    Here's the code that I used:

    Code:
    Public Class MyButton
       Inherits Button
       Public ID as Integer
    End Class

    Thanks techgnome!

Tags for this Thread

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