Results 1 to 4 of 4

Thread: Can I Assign A Component To A Variable?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Question

    Here is what I want to do:

    When I click on a command button, I want to assign the component object Command1 to a variable and then use it by the variable name.

    Like this:

    C1 = Command1

    and then say:

    C1.caption = "Click Here"

    Can someone give me an example of how to do this? I tried assigning C1 as Object and say C1 = Command1 but that does not work.

    Thanks in advance for your help!


  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    assign it as a commandbutton. You can't use default properties if you declare them as objects/controls, but you can of course do C1.Caption = "Click Here"
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463
    Great, thanks!

    There is no type I can assign C1 to that will work for alll components? I wanted to make a routine to use the same object/variable public in the app. Guess I can pass to the routine the variable and then a flag to tell which type it is like commandbutton, etc.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well you can pass it as control as well as object and then check the Typename of it, put it in a select case:
    Code:
    Select Case TypeName(C1)
       Case "CommandButton"
       Case "TextBox"
       Case Else
    End select
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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