随笔 - 493  文章 - 0  评论 - 97  阅读 - 239万

随笔分类 -  VBScript

1 2 下一页
vbs数组的使用
摘要:mu_Choose = "3"Dim i, sMethodif IsNumeric(mu_Choose) Then i = CInt(mu_Choose) if i < 1 or i > 4 Then i = 0 end ifelse i = 0end ifsMethod = Array("hh", "addition", "subtract", "multiply", "division")'sMethod(0) = "hh"' 阅读全文
posted @ 2011-03-01 22:39 清清飞扬 阅读(1330) 评论(0) 推荐(1) 编辑
vbs调用WebService -- 使用xmlhttp
摘要:具体调用的代码:'向指定的文件写入文本, 并指定是否是添加内容Function Z_WriteFile(sFileName, sText, bAppend) Dim fs, fso, iomode if bAppend = True Then iomode = 8 'ForAppending else iomode = 2 'ForWriting end if set fs = CreateObject("Scripting.FileSystemObject") set fso = fs.OpenTextFile(sFileName, iomode, 阅读全文
posted @ 2011-03-01 10:51 清清飞扬 阅读(3839) 评论(3) 推荐(0) 编辑
vbs过程参数--byref和byval
摘要:vbs过程参数--byref(默认)和byval请看例子:On error resume NextSub A1(byval s) s = s & "125"End SubFunction A2(byval s) s = s & "125" A2 = sEnd FunctionDim p1, p2, p3p1 = "what1"p2 = "what2"A1 p1p3 = A2(p2)MsgBox p1 & " : " & p2 & " : &quo 阅读全文
posted @ 2011-03-01 09:15 清清飞扬 阅读(1090) 评论(0) 推荐(0) 编辑
vbs向指定的日志文件添加日志
摘要:'向指定的文件写字符串,第三个参数指定是否删除原来的内容Function Z_WriteLog(sFileName, sText) Dim fs, fso, sLog sLog = Now() & ": " & sText set fs = CreateObject("Scripting.FileSystemObject") set fso = fs.OpenTextFile(sFileName, 8, True) '第三个参数表明文件不存在,则新建文件 fso.WriteLine sLog fso.Close set f 阅读全文
posted @ 2011-02-28 18:16 清清飞扬 阅读(1714) 评论(0) 推荐(0) 编辑
vbs向指定的文件添加内容
摘要:'向指定的文件写字符串,第三个参数指定是否删除原来的内容Function Z_WriteFile(sFileName, sText, bAppend) Dim fs, fso, iomode if bAppend = True Then iomode = 8 'ForAppending else iomode = 2 'ForWriting end if set fs = CreateObject("Scripting.FileSystemObject") set fso = fs.OpenTextFile(sFileName, iomode, Tr 阅读全文
posted @ 2011-02-28 17:59 清清飞扬 阅读(802) 评论(0) 推荐(0) 编辑
vbs创建目录,可循环创建父级目录
摘要:On error resume Next'删除字符串最右边的字符chsFunction MyRTrim(src, chs) '删除字符串最右边的字符chs(可多个) Dim pos, sLeft src = Trim(src) pos = InStrRev(src, chs) '查找最后一个字符chs if(pos > 0 and Len(Mid(src, pos+1)) = 0) Then sLeft = Left(src, pos - 1) '去除最后一个chs MyRTrim = MyRTrim(sLeft, chs) '去除尾部的chs e 阅读全文
posted @ 2011-02-28 14:54 清清飞扬 阅读(1430) 评论(0) 推荐(0) 编辑
vbs删除sFolder目录下,nDay之前的日志
摘要:'如文件名为:abc.txt, 则返回"abc"Function GetFileTitle(sFileName) '求文件的名称(不含扩展名) Dim pos pos = InStrRev(sFileName, ".") '从字符串尾部向前搜索子串(".") if(pos = 0) Then '文件无扩展名 GetFileTitle = sFileName else GetFileTitle = Left(sFileName, pos - 1) end ifEnd Function'删除sFol 阅读全文
posted @ 2011-02-27 16:59 清清飞扬 阅读(620) 评论(0) 推荐(0) 编辑
vbs根据文件名取得文件Title(文件名中不含扩展名的部分)
摘要:vbs根据文件名取得文件Title(文件名中不含扩展名的部分):'如文件名为:abc.txt, 则返回"abc"Function GetFileTitle(sFileName) '求文件的名称(不含扩展名) Dim pos pos = InStrRev(sFileName, ".") '从字符串尾部向前搜索子串(".") if(pos = 0) Then '文件无扩展名 GetFileTitle = sFileName else GetFileTitle = Left(sFileName, pos - 阅读全文
posted @ 2011-02-27 16:14 清清飞扬 阅读(875) 评论(0) 推荐(0) 编辑
vbscript时间函数
摘要:vbscript的时间函数有好大一堆,可是真的用起来的时候却不一定方便,因为各个函数的作用不一样,用法也不完全一样,所以常常出现不知道用哪个函数来实现某个功能的情况。以下就是偶搜集的和时间相关的函数极其用法,如果有不完整的或是错误的地方欢迎大家补充指正第一部分:对时间的判断与数据格式变化(1)IsDate(expression)expression 参数可以是任意可被识别为日期和时间的日期表达式或字符串表达式。返回Boolean值.判断expression是否为合法的日期格式如:IsDate("2004-10-25 13:14:20"其值为true(2)CDate(date 阅读全文
posted @ 2011-02-27 15:46 清清飞扬 阅读(5218) 评论(0) 推荐(0) 编辑
vbs获取目录下的文件和文件夹集合
摘要:Dim sFolder, sExt, messagesFolder = "F:\Programming\Applications\VBScript"Dim fs, oFolder, oFiles, oSubFoldersset fs = CreateObject("Scripting.FileSystemObject")set oFolder = fs.GetFolder(sFolder) '获取文件夹set oSubFolders = oFolder.SubFolders '获取子目录集合for each folder in oSubF 阅读全文
posted @ 2011-02-27 15:09 清清飞扬 阅读(10221) 评论(0) 推荐(0) 编辑
经典的vbs脚本 合集
摘要:1.文件下载(无回显) echo iLocal = LCase(WScript.Arguments(1)) >iget.vbe echo iRemote = LCase(WScript.Arguments(0)) >>iget.vbe echo Set xPost = createObject("Microsoft.XMLHTTP") >>iget.vbe echo xPost.Open "GET",iRemote,0 >>iget.vbe echo xPost.Send() >>iget.vbe e 阅读全文
posted @ 2011-02-27 13:10 清清飞扬 阅读(1487) 评论(0) 推荐(1) 编辑
vbs读取整个文本文件并输出
摘要:Const ForReading = 1Dim messageDim fs, tsset fs = CreateObject("Scripting.FileSystemObject")set ts = fs.OpenTextFile("1.txt", ForReading)Do Until ts.AtEndOfStream message = ts.ReadLine '即使是空行,也会被读一次 if message <> "" Then MsgBox message End ifLoopts.Closeset ts 阅读全文
posted @ 2011-02-26 22:10 清清飞扬 阅读(7700) 评论(0) 推荐(0) 编辑
vbs判断磁盘类型和检测硬盘剩余空间
摘要:Function ShowDriveType(drvpath) Dim fso, d, t Set fso = CreateObject("Scripting.FileSystemObject") Set d = fso.GetDrive(fso.GetDriveName(drvpath)) Select Case d.DriveType Case 0 t = "Unknown" Case 1 t = "Removable" '移动硬盘 Case 2 t = "Fixed" '硬盘 Case 3 t 阅读全文
posted @ 2011-02-26 21:39 清清飞扬 阅读(2123) 评论(0) 推荐(0) 编辑
vbs调用系统接口,帮你朗读文本
摘要:Dim messagemessage = "I love you baby, what can I do for you。我一定要找到你!" '经调试,发现不支持中文CreateObject("SAPI.SpVoice").speak message把上面的文件存到a.vbs文件,再双击运行看看,你就知道了。 阅读全文
posted @ 2011-02-26 21:03 清清飞扬 阅读(1364) 评论(0) 推荐(0) 编辑
检测文件夹是否存在,不存在则创建
摘要:On error resume NextDim mu_sFilePath, mu_sFileNamemu_sFilePath = "textFolder/"mu_sFileName = mu_sFilePath & "ResultVoice.txt"Dim fsset fs = CreateObject("Scripting.FileSystemObject")if(fs.FolderExists(mu_sFilePath)) Then '检测文件夹是否存在 MsgBox "文件夹已存在"else 阅读全文
posted @ 2011-02-25 17:17 清清飞扬 阅读(1067) 评论(0) 推荐(0) 编辑
vbs创建文本文件及检测文件是否存在
摘要:CreateTextFile 方法创建指定文件并返回 TextStream 对象,该对象可用于读或写创建的文件。object.CreateTextFile(filename[, overwrite[, unicode]])参数object必选项。应为 FileSystemObject 或 Folder 对象的名称。filename必选项。字符串表达式,指明要创建的文件。overwrite可选项。Boolean 值指明是否可以覆盖现有文件。如果可覆盖文件,该值为 True;如果不能覆盖文件,则该值为 False 。如果省略该值,则将覆盖现有文件。unicode可选项。Boolean 值指明是否以 阅读全文
posted @ 2011-02-25 16:58 清清飞扬 阅读(6761) 评论(1) 推荐(0) 编辑
conn.execute、rs.open、command.execute方法用法大大不同
摘要:通常形成记录集可以使用 Set rs=conn.execute(SQL) 或直接rs=CONN.execute(SQL)和 Set rs=Server.CreateObject("ADODB.Recordset")rs.open SQL,CONN,0,1 或 rs.open SQL,CONN这种情况 通常open比上一个性能要好那么一丁点( command对象更灵活,执行范围更广)使用 CONN.execute 可以不用关闭直接执行下一个 set rs=conn.execute(SQL)大约要慢 2~5倍!!(这是在msSQL循环1000次的),所以执行下一个 rs=con 阅读全文
posted @ 2011-02-24 17:34 清清飞扬 阅读(4055) 评论(1) 推荐(0) 编辑
VBScript执行插入记录--用Command
摘要:On error resume NextDim mu_ConnString, mu_InsertSqlmu_ConnString = "driver={SQL Server};Server=192.xx.xx.xx;database=TestFax;Uid=sa;pwd=xxx;" '连接SQL Server2005'mu_ConnString = "Provider=MSDAORA.1;Data Source=GSxx;User ID=GSxxx;Password=GSxxx" '连接Oracle数据库mu_InsertSql 阅读全文
posted @ 2011-02-24 17:14 清清飞扬 阅读(656) 评论(0) 推荐(0) 编辑
VBScript执行插入记录--用Connection
摘要:On error resume NextDim mu_ConnString, mu_InsertSqlmu_ConnString = "driver={SQL Server};Server=192.xx.xx.xx;database=TestFax;Uid=sa;pwd=zzz;" '连接SQL Server2005'mu_ConnString = "Provider=MSDAORA.1;Data Source=GSxxx;User ID=xx;Password=xxx" '连接Oracle数据库mu_InsertSql = &q 阅读全文
posted @ 2011-02-24 17:04 清清飞扬 阅读(531) 评论(0) 推荐(0) 编辑
vbscript调用存储过程(一)
摘要:VBScript代码可以直接放在.vbs文件中,双击直接运行。1. 数据库采用SQL Server2005,新建一个数据库,创建表T_UserInfo和存储过程Proc_T_AddUser-- 为测试建立的用户信息表Create Table T_UserInfo( UID int identity(1,1) primary key, -- 用户ID,主键,自动增长 UName varchar(20) not null, -- 用户姓名 UAge int default 0, -- 年龄 UMoney int default 0, -- 存款 InTime datetime default ge 阅读全文
posted @ 2011-02-24 16:48 清清飞扬 阅读(3452) 评论(2) 推荐(0) 编辑

1 2 下一页
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

点击右上角即可分享
微信分享提示