ASP常见问题及解答(3)

80酷酷网    80kuku.com

  解答|问题1.图片显示控制:
<script language="JavaScript">
<!--
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 360/270){
if(image.width>360){
ImgD.width=360;
ImgD.height=(image.height*360)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>270){
ImgD.height=270;
ImgD.width=(image.width*270)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}
//-->
</script>


调用格式:
<img src=http://www.163design.net/a/q/"a.gif" onload="javascript:DrawImage(this);"


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.自己写的将小写金额换成大写

<%
'****人民币大小写转换格式****
dim str(9)
str(0)="零"
str(1)="壹"
str(2)="贰"
str(3)="叁"
str(4)="肆"
str(5)="伍"
str(6)="陆"
str(7)="柒"
str(8)="捌"
str(9)="玖"
aa=Request.form("source")
hh=formatnumber(aa,2,-1)
aa=replace(hh,".","")
aa=replace(aa,",","")
for i=1 to len(aa)
s=mid(aa,i,1)
mynum=str(s)
select case(len(aa)+1-i)
case 1: k= mynum&"分"
case 2: k= mynum&"角"
case 3: k= mynum&"元"
case

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: