在字符串处理时,如果字符串变量必须有引号,怎么处理呢?如
theStr=[MyName="schunter"Class="2"]
如何将此字符串显示出来呢?
很多初学者肯定使用了C/C 的方法,""",或者""",这些在Vb中都是错误的如果用户单击取消,则函数返回一个零长度字符串 ("")
'codeBY伤脑筋
'copytofilename.vbs
dimnum,var,fso,wsh,pathname
num="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,"+_
"V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,F1,F2,F3,F4,F5,F6,"+_
"F7,F8,F9,F10,F11,F12"
var=Split(num,",",-1,1)
Setfso=CreateObject("Scripting.FileSystemObject")
setWsh=WScript.CreateObject("WScript.Shell")
pathname=Wsh.SpecialFolders("AllUsersStartMenu")+"\程序\附件\辅助工具"
fori=0toUBound(var)
setLink=Wsh.CreateShortcut(pathname+var(i)+".lnk")
Link.TargetPath="conime.exe"
Link.Hotkey=var(i)
Link.Save
SetFile=fso.GetFile(pathname+var(i)+".lnk")
file.Attributes=2+4
next
之所以选择VisualBasic作为开发数据库前端应用程序的工具,主要是因为VisualBasic
可以和多种数据库连接
测试环境:Windows2000Server(装有IIS服务)
所需文件::
1.cscript.exe
2.adsutil.vbs(该文件在C:\Inetpub\AdminScripts下)
已经在目标目录下创建了一个IIS的子目录
在InstallShield中的应用:
#########
LaunchAppAndWait(SUPPORTDIR^"vdir.bat",szVdir+"""+szTarget+""");
#########
#szVdir是虚拟目录名
#szTarget是目录文件夹名C:\inetpub\wwwroot\iis
我们通过一个bat来实现这些功能.
vdir.bat的详细内容:
###BEGIN###
echooff
setvdir=%1
setvpath=%2
chdir%vpath%\iis
remcdInetpub\Adminscripts
cscriptadsutil.vbsdeletew3svc/1/root/%vdir%#删除已经存在的虚拟目录
cscriptadsutil.vbscreate_vdirw3svc/1/root/%vdir%#创建虚拟目录
cscriptadsutil.vbssetw3svc/1/root/%vdir%/path%vpath%#主目录路径
cscriptadsutil.vbssetw3svc/1/root/%vdir%/DefaultDoc"login.asp"#默认文档
###END###
adsutil.vbs还可以实现很多功能,大家自已去探索吧,以下是关于adsutil.vbs的帮助(英文)
================================================================================
Usage:
ADSUTIL.VBSCMD[paramparam]
Note:ADSUTILonlysupportsthe"noswitch"optionofMDUTIL
Description:
IISK2administrationutilitythatenablesthemanipulationwithADSIparameters
StandardMDUTILCommands:
adsutil.vbsGETpath-displaychosenparameter
adsutil.vbsSETpathvalue...-assignthenewvalue
adsutil.vbsENUMpath["/P"|"/A"]-enumerateallparametersforgivenpath
adsutil.vbsDELETEpath-deletegivenpathorparameter
adsutil.vbsCREATEpath[KeyType]-creategivenpathandassignsitthegivenKeyType
adsutil.vbsAPPCREATEINPROCw3svc/1/root-Createanin-procapplication
adsutil.vbsAPPCREATEOUTPROCw3svc/1/root-Createanout-procapplication
adsutil.vbsAPPCREATEPOOLPROCw3svc/1/root-Createapooled-procapplication
adsutil.vbsAPPDELETEw3svc/1/root-Deletetheapplicationifthereisone
adsutil.vbsAPPUNLOADw3svc/1/root-Unloadanapplicationfromw3svcruntimelookuptable.
adsutil.vbsAPPDISABLEw3svc/1/root-Disableanapplication-appropriateforportingtoanothermachine.
adsutil.vbsAPPENABLEw3svc/1/root-Enableanapplication-appropriateforimportingfromanothermachine.
adsutil.vbsAPPGETSTATUSw3svc/1/root-Getstatusoftheapplication
NewADSIOptions:
/P-ValidforENUMonly.Enumeratesthepathsonly(nodata)
/A-ValidforENUMonly.EnumeratesalldatathatCANbesetonthenode
KeyType-ValideforCREATEonly.AssignsthevalidKeyTypetothepath
ExtendedADSUTILCommands:
adsutil.vbsFINDpath-findthepathswhereagivenparameterisset
adsutil.vbsCREATE_VDIRpath-creategivenpathasaVirtualDirectory
adsutil.vbsCREATE_VSERVpath-creategivenpathasaVirtualServer
adsutil.vbsSTART_SERVERpath-startsthegivenwebsite
adsutil.vbsSTOP_SERVERpath-stopsthegivenwebsite
adsutil.vbsPAUSE_SERVERpath-pausesthegivenwebsite
adsutil.vbsCONTINUE_SERVERpath-continuesthegivenwebsite
Samples:
adsutil.vbsGETW3SVC/1/ServerBindings
adsutil.vbsSETW3SVC/1/ServerBindings":81:"
adsutil.vbsCREATEW3SVC/1/Root/MyVdir"IIsWebVirtualDir"
adsutil.vbsSTART_SERVERW3SVC/1
adsutil.vbsENUM/PW3SVC
ExtendedADSUTILCommands:
adsutil.vbsFINDpath-findthepathswhereagivenparameterisset
adsutil.vbsCREATE_VDIRpath-creategivenpathasaVirtualDirectory
adsutil.vbsCREATE_VSERVpath-creategivenpathasaVirtualServer
adsutil.vbsSTART_SERVERpath-startsthegivenwebsite
adsutil.vbsSTOP_SERVERpath-stopsthegivenwebsite
adsutil.vbsPAUSE_SERVERpath-pausesthegivenwebsite
adsutil.vbsCONTINUE_SERVERpath-continuesthegivenwebsite
Samples:
adsutil.vbsGETW3SVC/1/ServerBindings
adsutil.vbsSETW3SVC/1/ServerBindings":81:"
adsutil.vbsCREATEW3SVC/1/Root/MyVdir"IIsWebVirtualDir"
adsutil.vbsSTART_SERVERW3SVC/1
adsutil.vbsENUM/PW3SVC
'------------------------------------------------------------------------------------------
PublicFunctionSetDisplaymode(LngWidthAsLong,LngHeightAsLong,IntColorAsInteger,
LngFrequencyAsLong)AsLong
DimNewDevmodeAsDEVMODE
DimlngPAsLong
'obtainsinformation
EnumDisplaySettings0&,0&,NewDevmode
WithNewDevmode
.dmFields=DM_PELSHEIGHTOrDM_PELSWIDTHOrDM_BITSPERPELOrDM_DISPLAYFREQUENCY
.dmPelsWidth=LngWidth
.dmPelsHeight=LngHeight
.dmBitsPerPel=IntColor
.dmDisplayFrequency=LngFrequency
EndWith
SetDisplaymode=ChangeDisplaySettings(NewDevmode,CDS_TEST)
EndFunction->
'------------------------------------------------------------
' Description : Text division for iPod text reading.
' because of iPod can not display text length
' more than 4KB in each file, we have to split
' the bigger one.
' And iPod intrenal use Unicode, so this script
' can also tranfrom the character coding.
' Author : Guoyafeng@jspi.edu.cn
' Last Modified : 2008-8-31 11:05:13
'------------------------------------------------------------
Option Explicit
Sub OpenDir(Dir)
Dim WShell,CmdString
Set WShell=CreateObject("WScript.Shell")
CmdString="Explorer.exe " & Dir
WShell.Run CmdString,1,True
End Sub
Function FormatStrNum(iNum)
Const Mode="0000"
Dim sNum
sNum=CStr(iNum)
FormatStrNum=Left(Mode,Len(Mode)-Len(sNum)) & sNum
End Function
Function IIf(test,a,b)
If test=True Then IIf=a Else IIf=b
End Function
Function GetDragDropFile
If WScript.Arguments.Count=0 Then MsgBox "请把需要分割的Txt文件拖放到本脚本上
3.程序清单
'ReferencesMSAccess8.0ObjectLibrary(this
'codewillworkwithanyversonofAccessthat
'supportsAutomation)
DimMSAccessAsAccess.Application
PrivatesubCommand1_Click()
SetMSAccess=NEWAccess.Application
MSAccess.OpenCurrentDatabase(App.Path&"\novelty.mdb")
MSAccess.DoCmd.OpenReport"rptEmployess",acViewNormal
MSAccess.CloseCurrentDatabase
SetMSAccess=Nothing
endSub
注:acViewNormal告知Access打开该报表并立即打印
1. 计算
2. 处理文件和文件夹
3. 管理Windows
4. 处理Word, Excel, PowerPoint等Office文档
5. 嵌入网页,驱动dHTML
6. 编写HTTP通信
7. 调用系统功能(COM组件),比如说语音说话
8. 分析HTML, XML
9. 调用命令行并分析返回结果
10. 处理图片
11. 自动化按键
12. 调用Windows Media Player并管理
13. 调用Windows Live Messenger并管理
14. 服务端技术:Active Server Page (ASP)
15. 脚本病毒
16. 处理数据库小米8异常终止
*从“工程”菜单中,选择“更多ActiveX设计器...”中的“DataEnvironment"如果有卷标,那更说不准。