+ Reply to Thread
Results 1 to 5 of 5

How to evaluate string?

  1. #1
    Registered User
    Join Date
    11-04-2005
    Posts
    4

    How to evaluate string?

    I have TextBox1 control on Form.

    I want to know how to evaluate string "TextBox1" as object?

    What I want is something like this:

    objectvar = Evaluate("TextBox1")

    I want to pass to objectvar evaluated string "TextBox1" and because TextBox1 is object it should be evaluated as object. How to do that?

  2. #2
    Chip Pearson
    Guest

    Re: How to evaluate string?

    Try something like

    MsgBox Evaluate(Me.Controls("TextBox1").Text)

    You should probably put in some error checking to ensure that the
    Text is numeric.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "Boban" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > I have TextBox1 control on Form.
    >
    > I want to know how to evaluate string "TextBox1" as object?
    >
    > What I want is something like this:
    >
    > objectvar = Evaluate("TextBox1")
    >
    > I want to pass to objectvar evaluated string "TextBox1" and
    > because
    > TextBox1 is object it should be evaluated as object. How to do
    > that?
    >
    >
    > --
    > Boban
    > ------------------------------------------------------------------------
    > Boban's Profile:
    > http://www.excelforum.com/member.php...o&userid=28560
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=482210
    >




  3. #3
    Registered User
    Join Date
    11-04-2005
    Posts
    4
    You didn't understand what I need.

    I need evaluation of variable so that evaluation returns reference to some variable.

    I want to evaluate string "TextBox1" which is actually object on a form and I need some function (or something) to evaluate that and to return object "TextBox1" to some variable.

  4. #4
    Tom Ogilvy
    Guest

    Re: How to evaluate string?

    Dim objvar as MSForms.Textbox

    set objvar = Userform1.Controls("Textbox1")

    or
    sStr = "TextBox1"
    set objvar = Userform1.Controls(sStr)
    --
    Regards,
    Tom Ogilvy

    "Boban" <[email protected]> wrote in
    message news:[email protected]...
    >
    > You didn't understand what I need.
    >
    > I need evaluation of variable so that evaluation returns reference to
    > some variable.
    >
    > I want to evaluate string "TextBox1" which is actually object on a form
    > and I need some function (or something) to evaluate that and to return
    > object "TextBox1" to some variable.
    >
    >
    > --
    > Boban
    > ------------------------------------------------------------------------
    > Boban's Profile:

    http://www.excelforum.com/member.php...o&userid=28560
    > View this thread: http://www.excelforum.com/showthread...hreadid=482210
    >




  5. #5
    Registered User
    Join Date
    11-04-2005
    Posts
    4
    Yes, thats what I needed!

    Thanks, have a drink on my account!

    Quote Originally Posted by Tom Ogilvy
    Dim objvar as MSForms.Textbox

    set objvar = Userform1.Controls("Textbox1")

    or
    sStr = "TextBox1"
    set objvar = Userform1.Controls(sStr)
    --
    Regards,
    Tom Ogilvy


+ 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