您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

一些源程序

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-02 01:22 点击:
Formats passed string based on length. Perfect for emails and text files.
---------------------------------------------------------------------------------------
<%
Company: Sabra Inc
Author: Dave Hoffenberg
Date: 10/5/00
Function: Formats passed string based on length.  Perfect for emails and text files.
Freeware

Function Padding(Value, Length)
If the length of the value is less than the variable length
If Len(Value) < Length Then
charcount = Length - len(Value)

for i = 1 to (charcount - 1)

padding = padding & " "

next

mystring = Value & padding
If the length of the value is greater than the variable length
Elseif len(Value) > Length Then
mystring = Left(Value,Length)

Else
set mystring = Value

End If

Padding = mystring

End Function


Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(Server.MapPath("test.txt"), True)

MyFile.WriteLine Padding("this is a test", 25) & "end of line."

Set fso = Nothing
Set MyFile = Nothing

response.write "done"
%>

Retrieves file size(K) of any file passed to it.
---------------------------------------------------------------------------

<%
Company: Sabra Inc
Author: Dave Hoffenberg
Function: Retrieves file size(K) of any file name passed to it.
Freeware

Function ShowFileSize(filespec)
    file = Server.MapPath(filespec)
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file) Then
    Set f = fso.GetFile(file)
intSizeB = f.Size
    intSizeK = Int((intSizeB/1024) + .5)
    If intSizeK = 0 Then intSizeK = 1
     ShowFileSize = intSizeK & "k"
Else
 ShowFileSize = "File Doesnt Exist"
End If
Set fso = Nothing
End Function

response.write ShowFileSize("test.txt")
%>

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • WAP常见问题问答大全(四)
      • ASP开发必备:WEB打印代码大全
      • ASP调用系统ping命令
      • asp缓存技术
      • ASP教程:第三篇 ASP基础
      • 用ASP+XML打造留言本(4)
      • 关于ASP Recordset 分页出现负数解决方法及建议
      • 用asp怎样编写文档搜索页面(5)
      • ASP处理多关键词查询实例代码
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1