ASP common several instance functions

Source: Internet
Author: User

1, check whether the file exists
Usage Example: If checkfile ("aa.jpg") = True Then Response.Write "OK"

Copy content to Clipboard program code
Function Checkfile (FileName)
On Error Resume Next
Dim Fsoobj
Set fsoobj = Server.CreateObject ("Scripting.FileSystemObject")
If not Fsoobj.fileexists (Server.MapPath (FileName)) Then
Checkfile = False
Exit Function
End If
Checkfile = True:set Fsoobj = Nothing
End Function

2. Detect the number of string occurrences

Parameter description: thechar= "string to detect", thestring= "string to be detected"
Usage Example: If Checkthechar ("A", "about") = 1 Then Response.Write "OK"
Copy content to Clipboard program code
Function Checkthechar (thechar,thestring)
If InStr (Thestring,thechar) Then
For n = 1 to Len (thestring)
If Mid (Thestring,n,len (TheChar)) = TheChar Then
Checkthechar = Checkthechar + 1
End If
Next
Checkthechar = Checkthechar
Else
Checkthechar = 0 ' "0 times"
End If
End Function

3, take the complete URL address

Copy content to Clipboard program code
Function GETURL ()
  Dim scriptaddress, M_itemurl, M_item
  Scrip taddress = CStr (Request.ServerVariables ("Script_name")) ' Get current address
  M_itemurl = '
  If (request.que Rystring <> "") Then
    scriptaddress =  scriptaddress & "?"
    for all m_item in Request.QueryString
      If InStr (Page,m_item) =0 Then
        m_itemurl = m_itemurl & m_item & "=" & Server.urlencod E (Request.QueryString ("&M_Item&"))   & "
      end If
 &nbs p;  Next
  End If
  GETURL = scriptaddress & m_itemurl
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.