Common functions in the development of ASP tutorials
Sub Lastnextpage (Pagecount,page,table_style,font_style)
' Generate previous page next page link
Dim query, A, X, temp
Action = "http://" & Request.ServerVariables ("Http_host") & Request.ServerVariables ("Script_name")
query = Split (Request.ServerVariables ("query_string"), "&")
For each x in query
A = Split (x, "=")
If StrComp (A (0), "page", vbTextCompare) <> 0 Then
Temp = temp & A (0) & "=" & A (1) & "&"
End If
Next
Response.Write ("<table" & Table_style & ">" & vbCrLf)
Response.Write ("<form method=get onsubmit=" "document.location = '" & Action & "" & Temp & "page=" + thi S.page.value;return false; "" ><tr> "& vbCrLf)
Response.Write ("<td align=right>" & vbCrLf)
Response.Write (Font_style & vbCrLf)
If Page<=1 Then
Response.Write ("Response.Write ("Else
Response.Write ("<a href=" & Action & "" & Temp & "page=1></a> ' & vbCrLf)
Response.Write ("<a href=" & Action & "?" & Temp & "Page=" & (page-1) & "></a> ' & vbCrLf)
End If
if Page>=pagecount then
response.write ( ' & vbCrLf '
response.write ( ' & vbCrLf)
else
response.write ("<a href=" & Action & "?" & Temp & "Page=" & (page+1) & "></a> ' & vbCrLf)
response.write ("<a href=" & Amp Action & "?" & Temp & "page=" & PageCount & "></a> ' & vbCrLf
end if
Response.Write ("Current <font color=red><b>" & Page &/"& PageCount &" </b></font> page "& vbCrLf)
' Response.Write (" <font color=red><b>" & All_num & "</b></font> Strip" & vbCrLf
Response.Write ("&" <input tyep=text name=page size=2 maxlength=5 style= ' height:17 ' value= ' "& Page &" ' > ' & "Page" & vbCrLf & "<input type=submit style=" "HEIGHT:16; Font-size:7pt "" value=go> ")
Response.Write ("</td>" & vbCrLf)
Response.Write ("</tr></form>" & vbCrLf)
Response.Write ("</table>" & vbCrLf)
End Sub
Sub Chkfod (fstring)
If Trim (fstring) <> empty Then
If Right (fstring, 1) <> "/" Then
fstring = fstring & "/"
End If
Dim i, TempDir
fstring = Split (fstring, "/")
For i = 1 To UBound (fstring)
If Trim (fstring (i)) <> empty Then
TempDir = tempdir & "/" & Fstring (i)
Set fso = CreateObject ("Scripting.FileSystemObject")
If Fso.folderexists (Server.MapPath (tempdir)) = False Then
Fso.createfolder (Server.MapPath (tempdir))
End If
Set fso = Nothing
Else
Exit For
End If
Next
End If
End Sub
REM Set random numbers
function Cdstr (Dlen)
' Response.Write Cdstr (9) ' specifies a random string with a length of 9
Dim Ss,sslen
Randomize Timer
Ss= "1234567890"
Sslen = Len (ss)
Cdstr = ""
For i = 1 to Dlen
t = CInt (Rnd*sslen) +1 "Add 1, otherwise mid (ss,0,1) will be faulted
Cdstr = Cdstr&mid (ss,t,1)
Next
End Function
' Check string length
function Strlength (str)
On Error Resume Next
Dim Winnt_chinese
Winnt_chinese = (len ("forum") =2)
If Winnt_chinese Then
Dim l,t,c
Dim i
L=len (str)
T=l
For I=1 to L
C=ASC (Mid (str,i,1))
If C<0 then c=c+65536
If c>255 Then
T=t+1
End If
Next
Strlength=t
Else
Strlength=len (str)
End If
If Err.number<>0 then Err.Clear
End Function