Results 1 to 4 of 4

Thread: Too Simple to Imagine for this form, but I need help.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Edmonton,AB, Canada
    Posts
    30

    Question

    I have a sample piece of code to look at a screen control
    and report on its properties. For example:

    Public Function fcnTest(strForm As String, _
    strControl As String) As String

    fcnTest = strScreen.strControl.Tag

    End function

    The problem comes in trying to get VB to replace strScreen and strControl with the form name and control name that is
    stored in each variable. So, if one calls the function like
    thus:

    strSomething = fcnTest("frmMain", "ctlPushButton")

    Inside my sample function should look like this, to VB
    any how after the compiler get through with it:

    Public Function fcnTest(strForm As String, _
    strControl As String) As String

    fcnTest = frmMain.cltPushButton.Tag

    End Function

    I am getting compile and run time errors.
    Can anyone help me with this truly basic, too basic, query?

    Thanks.
    David L. Baudais
    Systems Analyst


  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    strSomething = "fcnTest(""frmMain"", ""ctlPushButton"")"
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Edmonton,AB, Canada
    Posts
    30
    I do not understand or maybe I was not clear enough.
    Doesn't this
    strSomething = "fcnTest(""frmMain"", ""ctlPushButton"")"
    just store what is inbetween double quotes into the variable
    strSomething?

    What I am trying to do is to come up with a generic function
    so that I can pass the form name and the control name
    and then manipulate the properties of the control.

    Any more suggestions out there?

    Thanks.
    David L. Baudais
    Systems Analyst


  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Why don't you pass object variables?
    Instead of passing strings, you can pass a Form and a Control object. Even stronger: if you pass a reference to the control, you don't need to pass the form.
    eg
    Public Function fcnTest(MyControl As Control) As String

    fcnTest = MyControl.Tag

    End function

    You could call the function like this:
    strSomething = fcnTest(frmMain.ctlPushButton)
    or like this
    strSomething = fcnTest(Screen.ActiveControl)

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