Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default is there an Eval() in Excel VBA

Hi all,

I am going to handle a group of controls which are in
"txtControl1","txtControl2",
"txtControl3",... format. So, It is likely to use a loop in which the
"txtControl" part is concacted with the number part like "txtControl"&i, so I
like to use a Eval function to converse the string "txtControl"& i into
control. How can I do it?


CLara
--
thank you so much for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default is there an Eval() in Excel VBA

I'm not sure I entirely understand what you're trying to do, but this code
might be a start. It allows you to set an object reference to a control based
on the name.

Note that I dimensioned the controls with the generic term "Control" instead
of specifying "TextBox" or whatever they might be. Once you've got the
reference to the control, you can still access all the properties and methods
for that control even if they don't show up on the auto list members view.

Dim I As Integer
Dim C As Control, objMyControl As Control

I = 2 ' You can supply the value of I any way you want, from a parameter, etc.

For Each C In Me.Controls

If C.Name = "txtControl" & I Then

Set objMyControl = C
Exit For

End If


Next

' Do stuff with your control objMyControl


Set objMyControl = Nothing

--
Hmm...they have the Internet on COMPUTERS now!


"clara" wrote:

Hi all,

I am going to handle a group of controls which are in
"txtControl1","txtControl2",
"txtControl3",... format. So, It is likely to use a loop in which the
"txtControl" part is concacted with the number part like "txtControl"&i, so I
like to use a Eval function to converse the string "txtControl"& i into
control. How can I do it?


CLara
--
thank you so much for your help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default is there an Eval() in Excel VBA

HI MDW,

How can you converse the generic control variable c into a its original
format such textbox

Clara
--
thank you so much for your help


"MDW" wrote:

I'm not sure I entirely understand what you're trying to do, but this code
might be a start. It allows you to set an object reference to a control based
on the name.

Note that I dimensioned the controls with the generic term "Control" instead
of specifying "TextBox" or whatever they might be. Once you've got the
reference to the control, you can still access all the properties and methods
for that control even if they don't show up on the auto list members view.

Dim I As Integer
Dim C As Control, objMyControl As Control

I = 2 ' You can supply the value of I any way you want, from a parameter, etc.

For Each C In Me.Controls

If C.Name = "txtControl" & I Then

Set objMyControl = C
Exit For

End If


Next

' Do stuff with your control objMyControl


Set objMyControl = Nothing

--
Hmm...they have the Internet on COMPUTERS now!


"clara" wrote:

Hi all,

I am going to handle a group of controls which are in
"txtControl1","txtControl2",
"txtControl3",... format. So, It is likely to use a loop in which the
"txtControl" part is concacted with the number part like "txtControl"&i, so I
like to use a Eval function to converse the string "txtControl"& i into
control. How can I do it?


CLara
--
thank you so much for your help

  #4   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 145
Default is there an Eval() in Excel VBA

Form controls or Control Toolbox controls ?
On a form or an a worksheet?

Tim


"clara" wrote in message
...
Hi all,

I am going to handle a group of controls which are in
"txtControl1","txtControl2",
"txtControl3",... format. So, It is likely to use a loop in which the
"txtControl" part is concacted with the number part like "txtControl"&i,
so I
like to use a Eval function to converse the string "txtControl"& i into
control. How can I do it?


CLara
--
thank you so much for your help



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default is there an Eval() in Excel VBA

Try Typename(C)

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"clara" wrote in message
...
HI MDW,

How can you converse the generic control variable c into a its original
format such textbox

Clara
--
thank you so much for your help


"MDW" wrote:

I'm not sure I entirely understand what you're trying to do, but this
code
might be a start. It allows you to set an object reference to a control
based
on the name.

Note that I dimensioned the controls with the generic term "Control"
instead
of specifying "TextBox" or whatever they might be. Once you've got the
reference to the control, you can still access all the properties and
methods
for that control even if they don't show up on the auto list members
view.

Dim I As Integer
Dim C As Control, objMyControl As Control

I = 2 ' You can supply the value of I any way you want, from a parameter,
etc.

For Each C In Me.Controls

If C.Name = "txtControl" & I Then

Set objMyControl = C
Exit For

End If


Next

' Do stuff with your control objMyControl


Set objMyControl = Nothing

--
Hmm...they have the Internet on COMPUTERS now!


"clara" wrote:

Hi all,

I am going to handle a group of controls which are in
"txtControl1","txtControl2",
"txtControl3",... format. So, It is likely to use a loop in which the
"txtControl" part is concacted with the number part like
"txtControl"&i, so I
like to use a Eval function to converse the string "txtControl"& i into
control. How can I do it?


CLara
--
thank you so much for your help





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default is there an Eval() in Excel VBA

Hi Tim,

They are form controls
--
thank you so much for your help


"Tim" wrote:

Form controls or Control Toolbox controls ?
On a form or an a worksheet?

Tim


"clara" wrote in message
...
Hi all,

I am going to handle a group of controls which are in
"txtControl1","txtControl2",
"txtControl3",... format. So, It is likely to use a loop in which the
"txtControl" part is concacted with the number part like "txtControl"&i,
so I
like to use a Eval function to converse the string "txtControl"& i into
control. How can I do it?


CLara
--
thank you so much for your help




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
eval of concatenate function not displaying results tony12345 Excel Discussion (Misc queries) 1 March 6th 09 05:25 PM
press F2 to eval a cell, no color & no highlight Peggy C Excel Discussion (Misc queries) 0 October 8th 08 04:15 PM
Eval function with sum raffaello_ Excel Discussion (Misc queries) 0 May 31st 06 11:51 AM
Healthcare product eval & compare spreadsheet? Medcenter Mike Excel Discussion (Misc queries) 0 September 15th 05 03:53 PM


All times are GMT +1. The time now is 05:43 PM.

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

About Us

"It's about Microsoft Excel"