2025年保持刷新文本框中的值

保持刷新文本框中的值function FSOFileRead filename Dim objFSO objCountFile FiletempData Set objFSO Server CreateObject Scripting FileSystemOb Set objCountFile objFSO OpenTextFile Server MapPath filename 1

function FSOFileRead(filename)

Dim objFSO,objCountFile,FiletempData

Set objFSO = Server.CreateObject(“Scripting.FileSystemObject”)

Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)

FSOFileRead = objCountFile.ReadAll

objCountFile.Close

Set objCountFile=Nothing

Set objFSO = Nothing

End Function

””使用FSO读取文件某一行的函数

function FSOlinedit(filename,lineNum)

if linenum < 1 then exit function

dim fso,f,temparray,tempcnt

set fso = server.CreateObject(“scripting.filesystemobject”)

if not fso.fileExists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.AtEndofStream then

tempcnt = f.readall

f.close

set f = nothing

temparray = split(tempcnt,chr(13)&chr(10))

if lineNum>ubound(temparray)+1 then

exit function

else

FSOlinedit = temparray(lineNum-1)

end if

end if

end function

””使用FSO写文件某一行的函数

function FSOlinewrite(filename,lineNum,Linecontent)

if linenum < 1 then exit function

dim fso,f,temparray,tempCnt

set fso = server.CreateObject(“scripting.filesystemobject”)

if not fso.fileExists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.AtEndofStream then

tempcnt = f.readall

f.close

temparray = split(tempcnt,chr(13)&chr(10))

if lineNum>ubound(temparray)+1 then

exit function

else

temparray(lineNum-1) = lineContent

end if

tempcnt = join(temparray,chr(13)&chr(10))

set f = fso.createtextfile(server.mappath(filename),true)

f.write tempcnt

end if

f.close

set f = nothing

end function

””使用FSO添加文件新行的函数

function FSOappline(filename,Linecontent)

dim fso,f

set fso = server.CreateObject(“scripting.filesystemobject”)

if not fso.fileExists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),8,1)

f.write chr(13)&chr(10)&Linecontent

f.close

set f = nothing

end function

””读文件最后一行的函数

function FSOlastline(filename)

dim fso,f,temparray,tempcnt

set fso = server.CreateObject(“scripting.filesystemobject”)

if not fso.fileExists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.AtEndofStream then

tempcnt = f.readall

f.close

set f = nothing

temparray = split(tempcnt,chr(13)&chr(10))

FSOlastline = temparray(ubound(temparray))

end if

end function

‘还有,创建文件夹:

sub CreateFolder(Foldername)

Set afso = Server.CreateObject(“Scripting.FileSystemObject”)

if afso.folderexists(server.mappath(Foldername))=true then

else

afso.createfolder(server.mappath(foldername))

end if

set afso=nothing

end sub

‘用法,createfolder(foldername)

遍历目录以及目录下文件的函数

function bianli(path)

set fso=server.CreateObject(“scripting.filesystemobject”)

on error resume next

set objFolder=fso.GetFolder(path)

set objSubFolders=objFolder.Subfolders

for each objSubFolder in objSubFolders

nowpath=path + “/” + objSubFolder.name

Response.Write nowpath

set objFiles=objSubFolder.Files

for each objFile in objFiles

Response.Write “
—”

Response.Write objFile.name

next

Response.Write “



bianli(nowpath)’递归

next

set objFolder=nothing

set objSubFolders=nothing

set fso=nothing

end function

%>

<%

‘bianli(“d:”) ‘遍历d:盘

%>

<%

‘替换指定文件内字符串的函数

function FSOlineedit(filename,Target,String)

Dim objFSO,objCountFile,FiletempData

Set objFSO = Server.CreateObject(“Scripting.FileSystemObject”)

Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)

FiletempData = objCountFile.ReadAll

objCountFile.Close

FiletempData=Replace(FiletempData,Target,String)

Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)

objCountFile.Write FiletempData

objCountFile.Close

Set objCountFile=Nothing

Set objFSO = Nothing

End Function

response.write FSOlineedit(“test.txt”,”世界”,”明天是一个好天去”)

%>

保持刷新文本框中的值









保持刷新文本框中的值









ASP中连接数据库的5种方法

ASP中连接数据库的5种方法

(01-3-30 199)

from: chinaasp.com by caoli

第一种 – 这种方法用在ACCESS中最多

strconn = “DRIVER=Microsoft Access Driver (*.mdb);DBQ=” & Server.MapPath(“aspfree.mdb”)

set conn = server.createobject(“adodb.connection”)

conn.open strconn

第二种-这种方法用在SQL SERVER中多

strconn = “Driver={SQL

Server};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID;PWD=Password;DATABASE=Database_Name

set conn = server.createobject(“adodb.connection”)

conn.open strconn

第三种

strconn=”Driver={MicrosoftAccessDriver(*.mdb)};” &_

“DBQ=F:/Inetpub/wwwroot/somedir/db1.mdb;DefaultDir=f:/Inetpub/wwwroot/somedir;uid=LoginID;” &_

“pwd=Password;DriverId=25;FIL=MSAccess;” set conn = server.createobject(“adodb.connection”)

conn.open strconn

第四种运用系统数据源

The following uses a Data Source Name:

set conn = server.createobject(“adodb.connection”)

conn.open “Example”

第五种运用ODBC数据源,前提是你必须在控制面板的ODBC中设置数据源

set rs = server.createobject(“adodb.recordset”)

rs.open “tblname”, “DSNName”, 3, 3

汉字判断(js判断)

for(i=0;i
char=realname.charCodeAt(i);

if(!(char>255)){

alert(“真实姓名应为汉字!”);

userform.realname.focus();

return false;

}

} ”身份证真伪

”id 省份证号

”birthday生日,yyyy-mm-dd格式

”sex性别,值为”男:1″,”女:0″

id = “460102800925121”

birthday = “1980-09-25”

sex = 1

IF idcard_check(id,birthday,sex) Then

response.write “不错”

else

response.write “**”

End if

Function idcard_check(id,birthday,sex)

If len(id)<>15 and len(id)<>18 then

idcard_check=false

Exit Function

Else

For i=1 to len(id)

temp=mid(id,i,1)

If temp<“0″ or temp>”9” Then

idcard_check=False

Exit Function

End if

Next

bdl=left(birthday,4) & mid(birthday,6,2) & mid(birthday,9,2)

bds=mid(birthday,3,2) & mid(birthday,6,2) & mid(birthday,9,2)

If len(id)=15 Then

If mid(id,7,6)<>bds Then

idcard_check=False

Exit Function

End if

If int(mid(id,15,1)) Mod 2 = 1 And sex=1 Then

idcard_check=True

Exit Function

ElseIf int(mid(id,15,1)) Mod 2 = 0 And sex=0 Then

idcard_check=True

Exit Function

Else

idcard_check=False

Exit Function

End if

Else

If mid(id,7,8)<>bdl Then

idcard_check=False

Exit Function

End if

If int(mid(id,17,1)) Mod 2 = 1 And sex=1 Then

idcard_check=False

Exit Function

ElseIf int(mid(id,17,1)) Mod 2 = 0 And sex=0 Then

idcard_check=False

Exit Function

Else

idcard_check=False

Exit Function

End if

End if

End if

idcard_check=True

End function

11=”北京”

12=”天津”

13=”河北”

14=”山西”

15=”内蒙古”

21=”辽宁”

22=”吉林”

23=”黑龙江”

31=”上海”

32=”江苏”

33=”浙江”

34=”安徽”

35=”福建”

36=”江西”

37=”山东”

41=”河南”

42=”湖北”

43=”湖南”

44=”广东”

45=”广西”

46=”海南”

50=”重庆”

51=”四川”

52=”贵州”

53=”云南”

54=”西藏”

61=”陕西”

62=”甘肃”

63=”青海”

64=”宁夏”

65=”新疆”

71=”台湾”

81=”香港”

82=”澳门”

91=”国外”

生成一个不重复的随即数字

Sub CalCaPiao()

Dim strCaiPiaoNoArr() As String

Dim strSQL As String

Dim strCaiPiaoNo As String

strCaiPiaoNo = “01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33”

Dim StrTempArr(7) As String

Dim strZhongJiangArr(7) As String

strCaiPiaoNoArr = Split(strCaiPiaoNo, “,”)

Dim intRand As Integer

Dim i As Integer

Dim j As Integer

i = 0

Dim find As Boolean

Do While True

find = False

Randomize

intRand = Int((33 * Rnd) + 1)

For j = 0 To i – 1

If StrTempArr(j) = CStr(intRand) Then

find = True

End If

Next

If Not find Then

StrTempArr(j) = CStr(intRand)

strZhongJiangArr(i) = CStr(intRand)

‘Text1(i) = strZhongJiangArr(i)

i = i + 1

If i = 7 Then

Exit Do

End If

End If

Loop

End Sub

编程小号
上一篇 2025-03-21 11:11
下一篇 2025-07-02 18:57

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/129252.html