----下面有一段放在Form_Unload事件(或者其他退出模块中)中的一小段代码例子,它演示了关闭所有打开的DAO工作台、数据库和记录并释放了被这些对象占用的内存
dim a,b,c
a=inputbox ("请输入0-99的整数且不能重复更不要用汉字和字母")
b=inputbox ("请输入0-99的整数且不能重复更不要用汉字和字母")
c=inputbox ("请输入0-99的整数且不能重复更不要用汉字和字母")
if not(IsNUmberic(a) and IsNUmberic(b) and IsNUmberic(c)) then
msgbox "不乖哦>_
else
if a
d=b
b=a
a=d
end if
if c>b then
d=b
b=c
c=a
end if
if a
d=b
b=a
a=d
end if
msgbox a & " " & b & " " & c
end if虽然很多人觉得这个功能很鸡肋,但是以VBS的角度来看,UAC还是多多少少有点用的如果在代码中使用了数据控件如DAO,RDO,或ADO,在退出时应该关闭所有打开的recordset,database,和workspace
一道初中数学题,用VBS找到答案
未知数~i加上100成为一个完全平方数~X,i加上168成为另外一个完全平方数~Y,i,x,y都是正整数,求出i,x,y
---------------------------------------------------
n=0
msg1="未知数~i加上100成为一个完全平方数~X"+chr(10)
msg2="i加上168成为另外一个完全平方数~Y"+chr(10)+"i,x,y都是正整数"+chr(10)
l=inputbox(msg1+msg2+"请输入i的搜索范围,用来找到i,x,y.1~?:")
ifIsNumeric(l)then
msg4=l+"中搜索答案"
fori=1tol
x=int(sqr(i+100))
y=int(sqr(i+168))
ifx^2=i+100andy^2=i+168then
msg3="那么i,X,Y分别是:"+cstr(i)+","+cstr(x)+","+cstr(y)
msgboxmsg1+msg2+msg3,vbokonly,msg4
n=1
exitfor
endif
next
ifn=0then
msg3="那么没有找到合适的答案声明:
PublicTypeSHFILEOPSTRUCT
hwndAsLong
wFuncAsLong
pFromAsString
pToAsString
fFlagsAsInteger
fAnyOperationsAbortedAsLong
hNameMappingsAsLong
lpszProgressTitleAsLong
EndType
PublicDeclareFunctionSHFileOperationLib"shell32.dll"Alias"SHFileOperationA"(lpFileOpAsSHFILEOPSTRUCT)AsLong
PublicConstFO_DELETE=&H3
PublicConstFOF_ALLOWUNDO=&H40
代码:
DimSHopAsSHFILEOPSTRUCT
DimstrFileasstring
WithSHop
.wFunc=FO_DELETE
.pFrom=strFile Chr(0)
.fFlags=FOF_ALLOWUNDO
EndWith
SHFileOperationSHop->
解TOMDB
5.右键单击该DataGrid控件,然后单击“检索字段”
OnErrorResumeNext
SetArg=Wscript.arguments
IfArg.count=0thenWscript.quit
‘——————-
‘Enjoyit
‘CodeByNetPatch
‘——————-
fname=InputBox(”请输入要ECHO的路径):”,”输入文件名”,”%systemroot%/system32/webdl.vbs”)
SetFso=CreateObject(”Scripting.FileSystemObject”)
SetWshShell=Wscript.CreateObject(”Wscript.Shell”)
SetFile=Fso.OpenTextFile(Arg(0),1,False,-2)
Wscript.echo“点确定后5秒开始”
WshShell.AppActivate“命令提示符”
Wscript.Sleep5000
WshShell.AppActivate“命令提示符”
DoWhileFile.AtEndOfStream<>True
Data=File.readline
IfData=”"thenData=”.”
Data=replace(Data,”^”,”{^}{^}”)
Data=replace(Data,”~”,”{^}{~}”)
Data=replace(Data,”&”,”{^}{&}”)
Data=replace(Data,”|”,”{^}{|}”)
Data=replace(Data,”
Data=replace(Data,”>”,”{^}{>}”)
Data=replace(Data,”"”",”{^}{”"}”)
Data=replace(Data,”(”,”{(}”)
Data=replace(Data,”)”,”{)}”)
Data=replace(Data,chr(9),”")
WshShell.SendKeys“echo“&Data&”>>”&fname
Wscript.Sleep300
WshShell.SendKeys“{ENTER}”
Wscript.Sleep1000
Loop
File.close
SetFso=nothing
采集下载在VB中如何使用直观、简便的报表一直是很多人关心的问题,CrystalReports用起来又不太理想要获得WshShortcut对象,请使用WshShell.CreateShortcut方法。