home *** CD-ROM | disk | FTP | other *** search
/ distrib.akp.su/Programming/Vb-6+Rus/ / distrib.akp.su.tar / distrib.akp.su / Programming / Vb-6+Rus / VB98 / TEMPLATE / PROJECTS / DHTML.BAS < prev    next >
BASIC Source File  |  1998-06-18  |  2KB  |  43 lines

  1. Attribute VB_Name = "modDHTML"
  2. 'PutProperty: Store information in a cookie by calling this
  3. '             function.
  4. '             The required inputs are the named Property
  5. '             and the value of the property you would like to store.
  6. '
  7. '             Optional inputs are:
  8. '               expires : specifies a date that defines the valid life time
  9. '                         of the property.  Once the expiration date has been
  10. '                         reached, the property will no longer be stored or given out.
  11.  
  12. Public Sub PutProperty(objDocument As HTMLDocument, strName As String, vntValue As Variant, Optional Expires As Date)
  13.  
  14.      objDocument.cookie = strName & "=" & CStr(vntValue) & _
  15.         IIf(CLng(Expires) = 0, "", "; expires=" & Format(CStr(Expires), "ddd, dd-mmm-yy hh:mm:ss") & " GMT") ' & _
  16.  
  17. End Sub
  18.  
  19. 'GetProperty: Retrieve the value of a property by calling this
  20. '             function.  The required input is the named Property,
  21. '             and the return value of the function is the current value
  22. '             of the property.  If the proeprty cannot be found or has expired,
  23. '             then the return value will be an empty string.
  24. '
  25. Public Function GetProperty(objDocument As HTMLDocument, strName As String) As Variant
  26.     Dim aryCookies() As String
  27.     Dim strCookie As Variant
  28.     On Local Error GoTo NextCookie
  29.  
  30.     'Split the document cookie object into an array of cookies.
  31.     aryCookies = Split(objDocument.cookie, ";")
  32.     For Each strCookie In aryCookies
  33.         If Trim(VBA.Left(strCookie, InStr(strCookie, "=") - 1)) = Trim(strName) Then
  34.             GetProperty = Trim(Mid(strCookie, InStr(strCookie, "=") + 1))
  35.             Exit Function
  36.         End If
  37. NextCookie:
  38.         Err = 0
  39.     Next strCookie
  40. End Function
  41.  
  42.  
  43.