Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Evaluating an expression into a command

Status
Not open for further replies.

mark4444

MIS
Nov 29, 2001
2
0
0
GB
Hi,

I am looking for a function for converting a string into a command. Is there an "eval" type of function? For example

i = 3
SomeString="Hello"
"Textbox"&i&".Text = SomeString"

Then apply a function to achieve the following:

Textbox3.Text="Hello"

What is this function?

Many thanks,

Mark
 
To solve your example, just use an array of textboxes and use the index property. Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 

Code in Module

'=======================================================================================
Public Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long

Public Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean

ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0

End Function
'=======================================================================================

COde in FOrm
'=======================================================================================
Option Explicit

Private Sub Form_Click()
Dim str As String
str = "Form1.Backcolor=vbwhite"
ExecuteLine str
End Sub
'=======================================================================================

All the Best Praveen Menon
pcmin@rediffmail.com
 
Warning: EbExecuteLine is notoriously unreliable in compiled applications.

You'd be better off looking at the Eval and ExecuteStatement methods of the Microsoft Script Control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top