三个函数-数组赋值-下拉列表输出-取驱动器

类别:Asp 点击:0 评论:0 推荐:

<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style>
body{text-align:left;font:12px #000080 ;}
#main{float:left;width:680px;border:#0000ff 1px solid;margin:5px 20px;padding:10px 100px;}
#main p{}
</style>

</HEAD>

<BODY>
<div id="main">
<% 
 'Option Explicit
select case request("actionname")
  case "查找"
  call find(request("dirname"))
  case "进入"
  call enterdir(request("dirname"))
  case otherwise
  call showmain()
end select
 
 actionarray=storearrayvalue("查找,搜索,走吧,进入",",")
 drvname=split(showdrivelist,",")
 response.write "<form name=drv action=find.asp>"
 response.write writeselect(actionarray,actionname)
 response.write writeselect(drvname,dirname)
 response.write "<input type=submit name=action value=开始></form>"

'此函数用来给数组赋值,arrayvalue为要赋的字符串值,splitmethod为分割此字符串的依据

Function storearrayvalue(arrayvalue,splitmethod)
 storearrayvalue=split(arrayvalue,splitmethod)
End function

'此函数返回下拉列表字符串,arrayname为传入的数组名称,sltname为此下拉列表的名称 

Function writeselect(arrayname,sltname)
 dim slt,i
 slt="<select name=" & sltname & ">"
 for i=0 to ubound(arrayname)
  slt=slt & "<option value=" & arrayname(i) &">"   & arrayname(i) & "</option>"
 next
 slt=slt & "</select>"
 writeselect=slt
End function

'此函数返回所有驱动器

Function ShowDriveList
   Dim fso, d, dc,i,s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set dc = fso.Drives
   i=0
   For Each d in dc
    s=s&d.driveletter&","
   i=i+1
   Next
   s=mid(s,1,len(s)-1)
   showdrivelist=s
End Function

'此过程输出所选驱动器的容量状况.
showdriveinfo("e:\")
      Sub ShowDriveInfo(drvPath)
      Dim fso, drv, s
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set drv = fso.GetDrive(fso.GetDriveName(drvPath))
      s = "Drive " & UCase(drvPath) & " - "
      s = s & drv.VolumeName & "<br/>"
      s = s & "Total Space: " & FormatNumber(drv.TotalSize / (1024*1024*1024), -1)
      s = s & " GB" & "<br/>"
      s = s & "Free Space: " & FormatNumber(drv.FreeSpace / (1024*1024*1024), -1)
      s = s & " GB" & "<br/>"
      Response.Write s
      End Sub

%>
</div>
</body>
</html>

本文地址:http://com.8s8s.com/it/it7551.htm