Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
eval of concatenate function not displaying results | Excel Discussion (Misc queries) | |||
press F2 to eval a cell, no color & no highlight | Excel Discussion (Misc queries) | |||
Eval function with sum | Excel Discussion (Misc queries) | |||
Healthcare product eval & compare spreadsheet? | Excel Discussion (Misc queries) |