20 kwi 2008

Zapis stringa do pliku

Dim fso, stream, str, re, name
name = "page2.html"
Const ForWriting = 2, TristateUseDefault = -2
Set fso = CreateObject("Scripting.FileSystemObject")
 str = Replace(str, "–", "-")

'Set stream = fso.OpenTextFile("page_lot2.html",ForWriting, True ,TristateUseDefault)
stream.Write(str)
stream.Close
Set stream = Nothing
20 kwi 2008

Wczytanie pliku do zmiennej

'Constant  Value  Description
'TristateUseDefault  -2  Opens the file using the system default.
'TristateTrue  -1  Opens the file as Unicode.
'TristateFalse   0  Opens the file as ASCII.
Dim fso, stream, str, re, name
name = "moa.html"
Const ForReading = 1, ForWriting = 2, TristateTrue = -1, TristateFalse = 0, TristateUseDefault = -2
Set fso = CreateObject("Scripting.FileSystemObject")

Set stream = fso.OpenTextFile(name , ForReading, False, TristateFalse)
str = stream.ReadAll()
stream.Close
Set stream = Nothing
17 kwi 2008

Znaki cudzysłowia w VBS

myResult = "<table border=" & Chr(34) & "1" & Chr(34) & ">" & myResult & "</table>"
17 kwi 2008

Usunięcie ze stringa znaków sterujących

Dim strValue As String
          
strValue = Replace(strValue, Chr(13), "") 'enter
strValue = Replace(strValue, Chr(9), "") 'tab
strValue = Replace(strValue, Chr(10), "") 'newline
strValue = Replace(strValue, ":", "") 'colons
strValue = Trim(strValue) 'rtim
7 kwi 2008

Lista plików mp3

Dim fso, folder, plik, pliki, out
Set fso = CreateObject("Scripting.FileSystemObject")

sciezka  = "g:\mp3"
Set folder = fso.GetFolder(sciezka)
Set pliki = folder.Files
Set out  = fso.CreateTextFile("spis.txt")

For Each plik in pliki
'lista = lista &amp; " - " &amp; plik.path &amp; NewLine
  out.WriteLine (plik.path)
   Next