Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word - VBA Automation
Message
De
26/01/2001 06:15:45
 
 
À
25/01/2001 16:55:46
Evans Carl
System Answers Consulting, Inc
Big Lake, Minnesota, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00468404
Message ID:
00468955
Vues:
14
Hi Carl,

I think due to the different syntax and language construction, I find less need in VB for macro substitution. In fact even in VFP, I don't need macro substitution very often. We need it mostly in COMMANDS such as SELECT, REPLACE etc. Many of the situations in which we need to use & in VFP can be addressed in VB by building a string and passing the string to a method/property.

For example to build a SQL SELECT command dynamically in VFP, you would do something like this:

MyField = "Id"
MyTable = "FoxUser"
MyWhere = " WHERE Id LIKE 'WIND%'"

SELECT &MyField FROM (MyTable) &MyWhere

However, in VB, ADO, etc. you often pass a string containing the SQL SELECT to a method. The same applies in VFP when we use SPT:

lcConnectionStr = "Driver={Microsoft Visual FoxPro Driver};" +;
"SourceType=DBF;" +;
"SourceDB=C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VFP98\;" +;
"Exclusive=No;"

lnVFP = SQLSTRINGCONNECT(lcConnectionStr)

*-- build the SQL command
lcSqlCommand = "SELECT " + MyField + " FROM " + MyTable + " " + MyWhere

SQLEXEC(lnVFP, lcSqlCommand)

Or with ADO:

ioRecordSet.Open(lcSqlCommand, This.ioConnection, adOpenDynamic, adLockOptimistic)

In these cases we don't need macro substitution because we use functions or methods that receive the SQL command as a parameter.

HTH
Daniel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform