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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a formula as a string

Status
Not open for further replies.

rnpIII

Technical User
May 2, 2001
61
US
Good Morning All,

I have a series of files in a different set of directories.
Each set of files is different within itself (in naming convention).
I have made a formula, in one case, that I would like to pass to an all- purpose function that will parse some info and then zip the appropriate file.
So the formual is Mid(somefile,2,2), in this particular case.
I would like to pass this to the function because it will change when the directory changes because of the file naming structure.

I have tried the obvious: searchPattern = "Mid(somefile,2,2)"
Unfortunately this gives me just that when I pass searchpattern to the function, I can't seem to get it to actually become a formula again.

Example of issue:
Code:
sub getfileinfo
	SearchPattern = "Mid(fn,2,2)" 'this formula will change with each different file directory.
	funFileZip SearchPattern
End sub

Function funfileZip (SearchPattern)
	If SearchPattern = DateTarget Then		
		NewFileArray(i) = f
		Count = Count + 1
	End If
end Function

Needless to say this is just a mocked down sample of the actual code, which is a little more involved, although simple in keeping with my simple mind.

Any ideas, criticizms, suggestions will be greatly appreciated.

rnpIII
 
Have a look at the Eval function and/or the Execute statement.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
>[tt]If SearchPattern = DateTarget Then[/tt]
[tt]If eval(SearchPattern) = DateTarget Then[/tt]
 
Gentlemen,
Thank you for your succinct and correct answers. That worked perfectly.
It helps to answer someone who know.
Once again thank you, both of you.

I cannot tell you how much your site has helped me in my endeavor to learn vbscript. I don't usually even have to ask, I can just search. I just didn't really have a clue as to what to search for in this case.

rnpIII
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top