Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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?


--
Boban
------------------------------------------------------------------------
Boban's Profile: http://www.excelforum.com/member.php...o&userid=28560
View this thread: http://www.excelforum.com/showthread...hreadid=482210

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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"
wrote in message
...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to evaluate string?


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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in
message ...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to evaluate string?


Yes, thats what I needed!

Thanks, have a drink on my account!

Tom Ogilvy Wrote:
Dim objvar as MSForms.Textbox

set objvar = Userform1.Controls("Textbox1")

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





--
Boban
------------------------------------------------------------------------
Boban's Profile: http://www.excelforum.com/member.php...o&userid=28560
View this thread: http://www.excelforum.com/showthread...hreadid=482210



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a function that will evaluate a text string in a cell? Dave Excel Worksheet Functions 2 October 7th 09 04:25 AM
Evaluate text string as a function benb Excel Discussion (Misc queries) 3 July 19th 06 02:41 PM
Evaluate and execute a string Randall[_6_] Excel Programming 3 August 4th 05 05:19 PM
Evaluate string as a formula peacelittleone Excel Worksheet Functions 3 June 26th 05 06:20 PM
how to evaluate the content of a string as if it was a formula cyrille de brébisson Excel Discussion (Misc queries) 5 December 6th 04 10:47 PM


All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"