For i="1" to Datatable.GetRowCount
Dialog("Login").WinEdit("Agent Name:").Set DataTable("username", dtGlobalSheet)
Dialog("Login").WinEdit("assword:").Set DataTable("passwd", dtGlobalSheet)
Dialog("Login").WinButton("OK").Click
datatable.GlobalSheet.SetNextRow
Next
Function writeorderno(orderno)
Dim fso, myfile,username,passwd
Set fso="CreateObject(""scrīpting.FileSystemObject")
Set myfile="fso.openTextFile(""C:\testing.txt",1,false)
tmp=split(myfile.readline,",")
username=tmp(0)
passwd=tmp(1)
myfile.close
End Function
写文本文件的代码
Function writeorderno(orderno)
Dim fso, myfile
Set fso="CreateObject(""scrīpting.FileSystemObject")
Set myfile="fso.openTextFile(""C:\result1.txt",8,false)
myfile.writeline orderno
myfile.close
End Function
3 . EXCEL文件
我们可以把EXCEL文件当成数据文件,通过对EXCEL文件的读写操作,来实现数据驱动.
可以把EXCEL文件当作对象的方式来完成写的操作
Dim Excel,ExcelSheet
Set Excel="CreateObject(""Excel.Application")
Set ExcelSheet="CreateObject(""Excel.Sheet")
ExcelSheet.Application.visible=true
ExcelSheet.ActiveSheet.Cells(1,1).value=1
ExcelSheet.ActiveSheet.Cells(1,2).value=2
ExcelSheet.ActiveSheet.Cells(1,3).value=3
Excel.Save "C:\test.xls"
Set ExcelSheet="Nothing
用ADO的方式连接EXCEL文件来做读的操作
Dim conn,input,filename
filename="D:\公基本情况(tb_gsgk)-标准格式.xls" '
Set conn= createobject("ADODB.Connection")
conn.Open "rovider="Microsoft.Jet.OLEDB.4.0ersist" Security Info="False;Data" Source="&filename&";Extended Properties="'Excel" 8.0;hdr="yes'""
Set input= createobject("ADODB.Recordset")
input.Open "select * from [公基本情况-标准格式$] " ,conn,2,2
input.close
Set input="nothing
Dim res,cmd,sql
Set Res="createobject(""adodb.recordset")
Set Cmd="createobject(""adodb.command")
Cmd.activeconnection="rovider=SQLOLEDB.1assword=111111ersist Security Info="True;User" ID="sa;Initial" Catalog="xhq;Data" Source="192.168.191.142"" '这句话是连接数据库的数据源,要做修改
Cmd.CommandType = 1
sql ="selec t * from 表 where name="username""
Cmd.CommandText = sql
Set res = Cmd.Execute()
Set res = nothing
Set cmd.ActiveConnection = nothing
Set Cmd= nothing