Discussion Locked

VB Macro Substitution

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi! We are converting Visual FoxPro(VFP) applications to Visual Basic 6(VB) and one of the features in VFP is "MAcro Substitution".We could store a command into a variable and execute what was contained in variable. For Ex:
x="me."+rtrim(gareqfield(n))+".setfocus"
In VB it appears we have to hard code the routine.For Ex:
if gareqfield(n)="Text1" then
me.textfields(1).setfocus
endif
Is there any macro substitution?How can we use macro substitution.

ThanksSridhar

7 replies

by for_serge

Unfortunately, VB has not macro substitution.
I can suggest one trick to solve problem you described.
Place the following sub in your form:
Private Sub FocusControlByName (strControlName As String)
Dim ctl As Control
Set ctl = CallByName(Me, strControlName, VbGet)
ctl.SetFocus
Set ctl = Nothing
End Sub

Now, you can focus your control just like
in your VFP example:

FocusControlByName Trim$(gareqfield(n))

Please, review CallByName function help for more information.

Serge

by donq

I have no clue if this will work however since everything is Microsoft's you might give it a shot.

Access 2000 will open a FoxPro application and convert everything into VBA. Then Access has some tools to automatically convery an Access Macro into a procedure and/or code snippet you could attach to the appropriate event.

You could let Microsoft'e cross compatability features automate everything for you. At least that's what they advertise? Good Luck.

by dtucker

Although FoxPro allows the following:
x="me."+rteim(gareqfield(n))+".setfocus
&x

VB has no macro substitution facility.

We have ported a number of applications from Foxpro (both Visual and ver 2.6) and have often wished for a substitution utility.
If you locate any information on a usefull workaround, we'd like to hear of it.

This discussion is closed to new replies.