繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP基础 >> ASP常见问题及解答(3)

ASP常见问题及解答(3)

2006-04-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:调用格式: 2.用ASP把doc转换成HTML doc2HTML.vbs '********************************************************** ' ' 调用方法:doc2HTML c:\doc2HTML c:\doc2HTML ' 调用方法:doc2HTML -s c:\doc2HTML...
关键字:常见问题 解答 ASP

调用格式:

2.用ASP把doc转换成HTML

doc2HTML.vbs

'**********************************************************

'

' 调用方法:doc2HTML c:\doc2HTML c:\doc2HTML

' 调用方法:doc2HTML -s c:\doc2HTML\a.doc c:\doc2HTML

'

'**********************************************************

Dim Objword

Dim Objdoc

Dim Objfso

Dim Strsource

Dim Strtarget

Dim Bbatch

'得到命令行参数,有三种可能的格式:[-s] 要进行转换的源文件目录或文件 转换成HTML文件后保存的目录

Function Getparams()

Dim Objarg

If Wscript.Arguments.Count >= 2 Then

If Wscript.Arguments.Item(0) = "-s" Or Wscript.Arguments.Item(0) = "-S" Then

Strsource = Wscript.Arguments.Item(1)

Strtarget = Wscript.Arguments.Item(2)

Bbatch = False

Else

Strsource = Wscript.Arguments.Item(0)

Strtarget = Wscript.Arguments.Item(1)

Bbatch = True

End If

Else

Wscript.Quit(1)

End If

End Function

Function Batchprocessing()

Dim Objfolder

Dim Objfile

Dim Lpos

Dim Strfilename

Lpos = 0

Set Objfolder = Objfso.Getfolder(Strsource)

For Each Objfile In Objfolder.Files

Lpos = Instr(1,Mid(Objfile.Path,Len(Objfile.Path) - 3,4),"Doc",1)

If Lpos > 0 Then

Strfilename = Objfso.Getbasename(Objfile.Path)

wordinterface Objfile.Path,Strfilename

End If

Next

End Function

Function Singleprocessing()

Dim Objfile

Set Objfile = Objfso.Getfile(Strsource)

Strfilename = Objfso.Getbasename(Objfile.Path)

wordinterface Objfile.Path,Strfilename

End Function

Function wordinterface(Strfilename,Formattedfilename)

Objword.Documents.Open Strfilename

Set Objdoc = Objword.Activedocument

'Stop

'set The Title Of The Document To Match The Filename

Objdoc.Builtindocumentproperties(1) = Formattedfilename

'1 = Wdpropertytitle In Vba

Objdoc.Saveas Strtarget & "\" & Formattedfilename & ".htm",8

'objdoc.Saveas "C:\Doc2HTML\" & Formattedfilename & ".htm",8

On Error Resume Next

Objdoc.Close

End Function

'stop

Set Objfso = Createobject("Scripting.FileSystemObject")

Set Objword = Createobject("word.Application")

Objword.Visible = False

Call Getparams

If Bbatch Then

Call Batchprocessing

Else

Call Singleprocessing

End If

Objword.Quit

Set Objword = Nothing

3.自己写的将小写金额换成大写

数字转换

Elseif(s=".") then

n=m

i=i+2

for j=i to len(aa)

s=mid(aa,i,1)

mynum=str(s)

select case(len(aa)+1-i)

case 1: p= mynum&"分"

case 2: p= mynum&"角"

end select

m=m&p

next

-->

=

4.获取中文字符串拼音首字母串的函数

<%

response.write ""

if request.form("content")="" then

response.write "__"

else

function getpychar(char)

tmp=65536+asc(char)

if(tmp>=45217 and tmp=45253 and tmp=45761 and tmp=46318 and tmp=46826 and tmp=47010 and tmp=47297 and tmp=47614 and tmp=48119 and tmp=49062 and tmp=49324 and tmp=49896 and tmp=50371 and tmp=50614 and tmp=50622 and tmp=50906 and tmp=51387 and tmp=51446 and tmp=52218 and tmp=52698 and tmp=52980 and tmp=53689 and tmp=54481 and tmp<=62289) then

getpychar= "Z"

else '如果不是中文,则不处理

getpychar=char

end if

end function

function getpy(str)

for i=1 to len(str)

getpy=getpy&getpychar(mid(str,i,1))

next

end function

content=request.form("content")

response.write ""&getpy(content)&chr(10)

response.write "

返回"

end if

%>

5.ip限制函数

'******************************

'Function CheckIp(cInput_Ip,cBound_Ip)

'Created by qqdao, qqdao@263.net 2001/11/28

'说明:首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内

'参数: cInput_Ip,代检查的ip

' cBound_Ip,给定的范围格式为,单个ip,和范围ip,范围ip最后使用”-“分割,如果是“*”则必须放到最后一位

' 每个范围后添加":ALLOW"表示允许登陆,添加":REFUSE"表示拒绝登陆。多个范围用”;“隔开

' 例如192.168.1*.*:ALLOW;192.168.1.1:ALLOW;192.168.1.1-10:REFUSE"

'返回值: true/false

'更新:2001/12/05 支持ALLOW,REFUSE支持’*‘,不想对?支持,因为和*差不多

'******************************

function CheckIp(cInput_Ip,cBound_Ip)

dim cSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip

CheckIp = false

cSingle_Ip=split(cBound_Ip,";")

for i=0 to ubound(cSingle_Ip)

if Instr(cSingle_Ip(i),"REFUSE") 0 then '就是拒绝了

cTemp_IP = left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)

if Instr(cTemp_IP,"*") 0 then '是宽范围

cStart_IP = left(cTemp_IP,instr(cTemp_IP,"*")-1)

if left(cInput_Ip,len(cStart_IP))=cStart_IP then

CheckIp = false

exit function

end if

end if

if Instr(cTemp_IP,"-") = 0 then

cStart_IP = cTemp_IP

cEnd_Ip = cTemp_IP

else

cStart_IP = left(cTemp_IP,instr(cTemp_IP,"-")-1)

cEnd_Ip = left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)

end if

if Ip2Str(cInput_Ip)>=Ip2Str(cStart_IP) and Ip2Str(cInput_Ip)<=Ip2Str(cEnd_Ip) then

CheckIp = false

exit function

end if

elseif Instr(cSingle_Ip(i),"ALLOW") 0 then '允许

cTemp_IP = left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)

if Instr(cTemp_IP,"*") 0 then '是宽范围

cStart_IP = left(cTemp_IP,instr(cTemp_IP,"*")-1)

if left(cInput_Ip,len(cStart_IP))=cStart_IP then

CheckIp = true

end if

end if

if Instr(cTemp_IP,"-") = 0 then

cStart_IP = cTemp_IP

cEnd_Ip = cTemp_IP

else

cStart_IP = left(cTemp_IP,instr(cTemp_IP,"-")-1)

cEnd_Ip = left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)

end if

if Ip2Str(cInput_Ip)>=Ip2Str(cStart_IP) and Ip2Str(cInput_Ip)<=Ip2Str(cEnd_Ip) then

CheckIp =true

else

CheckIp =false

end if

end if

next

end function

责任编辑:admin
相关文章