+ Reply to Thread
Results 1 to 4 of 4

Returning a value from a form

  1. #1
    Blue Aardvark
    Guest

    Returning a value from a form

    Hello

    I would like a form I have built to return a value to the sub that called
    it. The built in dialog boxes, like the OK/Cancel one do this. Anyone know
    how this can be achieved?

    Thanks,
    Steve

  2. #2
    Bob Phillips
    Guest

    Re: Returning a value from a form

    Create a Public variable in a standard code module, set that in the
    userform, read it after exiting the userform.

    --

    HTH

    Bob Phillips

    (replace xxxx in the email address with gmail if mailing direct)

    "Blue Aardvark" <BlueAardvark@discussions.microsoft.com> wrote in message
    news:D8079DF7-BF48-48F9-B256-FE05D178EC67@microsoft.com...
    > Hello
    >
    > I would like a form I have built to return a value to the sub that called
    > it. The built in dialog boxes, like the OK/Cancel one do this. Anyone know
    > how this can be achieved?
    >
    > Thanks,
    > Steve




  3. #3
    Blue Aardvark
    Guest

    Re: Returning a value from a form

    Thanks. Thats nice and simple. But is there no slick way of doing it? Or do
    the inbuilt dailogs do exactly the same thing, but just hide the public
    variable away.

    "Bob Phillips" wrote:

    > Create a Public variable in a standard code module, set that in the
    > userform, read it after exiting the userform.
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (replace xxxx in the email address with gmail if mailing direct)
    >
    > "Blue Aardvark" <BlueAardvark@discussions.microsoft.com> wrote in message
    > news:D8079DF7-BF48-48F9-B256-FE05D178EC67@microsoft.com...
    > > Hello
    > >
    > > I would like a form I have built to return a value to the sub that called
    > > it. The built in dialog boxes, like the OK/Cancel one do this. Anyone know
    > > how this can be achieved?
    > >
    > > Thanks,
    > > Steve

    >
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: Returning a value from a form

    No, because a Userform is not a method, whereas MsgBox is. A Userform is a
    class module, so you can set a Public property within that and read it on
    exit with

    Userform1.myVar

    but for this you cannot unload the userform, you have to hide it (Otherwise
    the property is unloaded with it).

    --

    HTH

    Bob Phillips

    (replace xxxx in the email address with gmail if mailing direct)

    "Blue Aardvark" <BlueAardvark@discussions.microsoft.com> wrote in message
    news:F1011392-B9F0-4390-9B3E-C50929EDA0C2@microsoft.com...
    > Thanks. Thats nice and simple. But is there no slick way of doing it? Or

    do
    > the inbuilt dailogs do exactly the same thing, but just hide the public
    > variable away.
    >
    > "Bob Phillips" wrote:
    >
    > > Create a Public variable in a standard code module, set that in the
    > > userform, read it after exiting the userform.
    > >
    > > --
    > >
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (replace xxxx in the email address with gmail if mailing direct)
    > >
    > > "Blue Aardvark" <BlueAardvark@discussions.microsoft.com> wrote in

    message
    > > news:D8079DF7-BF48-48F9-B256-FE05D178EC67@microsoft.com...
    > > > Hello
    > > >
    > > > I would like a form I have built to return a value to the sub that

    called
    > > > it. The built in dialog boxes, like the OK/Cancel one do this. Anyone

    know
    > > > how this can be achieved?
    > > >
    > > > Thanks,
    > > > Steve

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1