>I would like to write these codes in VB
>
>1 – open a VFP table (independent table and table in a database)
> if not used(“mytable”)
> use mytable in 0
> endif
> select mytable
>
>2 – search a record in a table
> locate for xfield=xvar
> if found()
> endif
>
>3 – Write in a table
> replace xfield with xvar
>
>4 – name of the computer
> xmac=alltr(sys(0))
> xmac=upper(alltr(substr(xmac,1,at('#',xmac)-1)))
>
>5 – create a table or cursor
> CREATE CURSOR csResult (field1 I)
> CREATE table csResult (field1 I)
>
>6 – scan a table
> select mytable
> scan
> endscan
>
>7 – does a file exist
> if file(“c:\myfile.dbf”)
> endif
Martin,
There are multiple ways to do that from VB. One way is to use ADO and there are many samples here and elsewhere and on MSDN online (ie: ADO jumpstart for VFP developers by JVP)
Another way is to do that in the laguage you know - VFP and create a COM DLL using OLEPUBLIC keyword in class definition. ie :
define class myRoutines as session Olepublic
Datasession=2
procedure SearchARecordInaTable
lparameters tcTableName, tcField, tuValue
use (tcTableName)
locate for eval(tcField)=tuValue
if found()
endif
endproc
enddefine
Assuming you created myVFP project for the above and compiled to DLL :
set oVFP = createobject('myVFP.myRoutines')
oVFP.SearchARecordInaTable(ParamsHere)
Another option is to use ready VFP ole automation object :
set oVFP = createobject('VFP.Application')
oVFP.DoCmd('SomeVFPCommand')
The more natural one for your purpose might be ADO way.
Cetin