推荐:解读asp调用子程序教程ASP程序可通过VBScript和其他方式调用子程序。 调用使用VBScript的子程序,示例代码: html head % subvbproc(num1,num2) response.write(num1*num2) endsub % /head body p您可以像这样调用一个程序:/p p结果:%callvbproc(3,4)%/p p或者,像这样:/p p结果
指定的驱动器存在吗? 本例演示如何使用DriveExists方法来探测某个驱动器是否存在。代码如下:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) iffs.driveexists(c:)=truethen Response.Write(驱动器c:存在。) Else Response.Write(驱动器c:不存在。) EndIf Response.write(<br>) iffs.driveexists(g:)=truethen Response.Write(驱动器g:存在。) Else Response.Write(驱动器g:不存在。) EndIf setfs=nothing %> </body> </html> |
本实例运行结果如下:
驱动器c:存在。
驱动器g:存在。
取得某个指定驱动器的名称
本例演示如何使用GetDriveName方法来取得某个指定的驱动器的名称。
代码如下:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) p=fs.GetDriveName(c:/windows/cursors/abc.cur) Response.Write(驱动器名称是:&p) setfs=nothing %> </body> </html> |
本实例运行结果如下:
驱动器名称是:c:
指定的文件存在吗?
本例演示如何首先创建FileSystemObject对象,然后使用FileExists方法来探测某文件是否存在。
代码如下:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) If(fs.FileExists(c:/windows/cursors/xxx.cur))=trueThen Response.Write(文件c:/windows/cursors/xxx.cur存在。) Else Response.Write(文件c:/windows/cursors/xxx.cur不存在。) EndIf setfs=nothing %> </body> </html> |
本实例运行结果如下:
文件c:/windows/cursors/xxx.cur不存在。
指定的文件夹存在吗?
本例演示如何使用FolderExists方法探测某文件夹是否存在。
本示例代码如下:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) Iffs.FolderExists(c:/temp)=trueThen Response.Write(文件夹c:/temp存在。) Else Response.Write(文件夹c:/temp不存在。) EndIf setfs=nothing %> </body> </html> |
本实例运行结果如下:
文件夹c:/temp不存在。
取得某个指定路径的父文件夹的名称
本例演示如何使用GetParentFolderName方法来取得某个指定的路径的父文件夹的名称。
代码如下:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) p=fs.GetParentFolderName(c:/winnt/cursors/3dgarro.cur) Response.Write(c:/windows/cursors/abc.cur的父文件夹名称是:&p) setfs=nothing %> </body> </html> |
本实例运行结果如下:
c:/windows/cursors/abc.cur的父文件夹名称是:c:/winnt/cursors
取得文件夹扩展名
本例演示如何使用GetExtensionName方法来取得指定的路径中的最后一个成分的文件扩展名。
代码如下:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) Response.Write(文件3dgarro的文件扩展名是:) Response.Write(fs.GetExtensionName(c:/windows/cursors/abc.cur)) setfs=nothing %> </body> </html> |
本实例运行结果如下:
文件3dgarro的文件扩展名是:cur
取得文件名
本例演示如何使用GetFileName方法来取得指定的路径中的最后一个成分的文件名。
代码如下:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) Response.Write(这个文件名的最后一个成分是:) Response.Write(fs.GetFileName(c:/windows/cursors/abc.cur)) setfs=nothing %> </body> </html> |
本实例运行结果如下:
这个文件名的最后一个成分是:abc.cur
取得文件或文件夹的基名称
本例演示如何使用GetBaseName方法来返回在指定的路径中文件或者文件夹的基名称。
代码如下:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) Response.Write(fs.GetBaseName(c:/windows/cursors/abc.cur)) Response.Write(<br/>) Response.Write(fs.GetBaseName(c:/windows/cursors/)) Response.Write(<br/>) Response.Write(fs.GetBaseName(c:/windows/)) setfs=nothing %> </body> </html> |
本实例运行结果如下:
| abc cursors windows |
分享:解析ASP日期格式的数据加减计算方法在ASP中为我们提供了专门的日期加减函数。 1.日期相加 DateAdd函数 返回已添加指定时间间隔的日期。 DateAdd(interval,number,date) DateAdd函数的语法有以下参数 (1)interval必选项。字符串表达式,表示要添加的时间间隔。有关数值,请参阅“设置”部分。