Category: VBscript


VBScript

Division with 2 Decimal Digits

     aLeft = 190100
     aRight = 190 mod 100
     Height = aLeft & “.” & aRight

 

In this case, i do a replace of the chars that are not accepted in a file name.

myStr = myReplace(myStr)

function myReplace(myStr)
         myStr = Replace(myStr, “/”, “”)
         myStr = Replace(myStr, “\”,”")
         myStr = Replace(myStr, “*”,”")
         myStr = Replace(myStr, “:”,”")
         myStr = Replace(myStr, “?”,”")
         myStr = Replace(myStr, “<”,”")
         myStr = Replace(myStr, “>”,”")
         myStr = Replace(myStr, “|”,”")
         myStr = Replace(myStr, “”"”, “”)

         myReplace = myStr
end function 

Function ReadSiteFile(strHDLocation)
  Const ForReading = 1
  Set fso = CreateObject(“Scripting.FileSystemObject”)
  Set theFile = fso.OpenTextFile(strHDLocation, ForReading, False)
  idx = 0
  Do Until theFile.AtEndOfStream
     retstring = theFile.Readline
     idx = idx + 1
     Redim Preserve HtmlTxt(idx)
     HtmlTxt(idx – 1) = retstring
  Loop
  theFile.Close
  ReadSiteFile = HtmlTxt
End Function 
Sub XMLImport(strFileURL, strHDLocation)
 Set objXMLHTTP = CreateObject(“MSXML2.XMLHTTP”)
 objXMLHTTP.open “GET”,  strFileURL, false
 objXMLHTTP.send
 If objXMLHTTP.Status = 200 Then ‘ “URL Exists!”
    Set objADOStream = CreateObject(“ADODB.Stream”)
    with objADOStream  
         .Open
         .Type = 1
         .Write objXMLHTTP.ResponseBody
         .Position = 0
    End with
    Set objFSO = Createobject(“Scripting.FileSystemObject”)
    If objFSO.Fileexists(strHDLocation) Then
       objFSO.DeleteFile strHDLocation
    End if
    Set objFSO = Nothing
    objADOStream.SaveToFile strHDLocation
    objADOStream.Close
    Set objADOStream = Nothing
 End if
 Set objXMLHTTP = Nothing
End Sub
Follow

Get every new post delivered to your Inbox.