![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | [ann] code sample to convert html to vb or vbs... hi groupies, o.k., so this is pretty trivial, but may save somebody the 10 minutes or so that it would take to write for yourself. There are some webpages which present sample code which is embedded in "pre" tags -- and so the lines don't end with vbCrLf's, rather they end with "br" tags. Also, there are other re-codings, such as the ampersand, less than, greater than, and etc. Here is the code used to convert some (html-formatted) source code back into vb/vbs source. The procedure was to "view source" on the html page showing the code, extract the text inside the "pre" tags, and then run this: --- <code> --- Const htmlFile = "callDLL_Example1.txt" Const basFile = "callDLL_Example1.bas" Const ForReading = 1, ForWriting = 2 Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") Dim oFile : Set oFile = fso.OpenTextFile(htmlFile, ForReading) Dim fHTML : fHTML = oFile.ReadAll Dim fBAS fBAS = Replace(fHTMl, "<br>", vbCrLf) fBAS = Replace(fBAS, " ", " ") fBAS = Replace(fBAS, " ", " ") fBAS = Replace(fBAS, "&", "&") fBAS = Replace(fBAS, "<", "<") fBAS = Replace(fBAS, ">", ">") Set oFile = fso.OpenTextFile(basFile, ForWriting, True) oFile.Write fBAS oFile.Close MsgBox("finished") WScript.Quit --- </code> --- As you can probably tell, the script assumes that all the relevant files (including the script itself) are all located in the current working directory. cheers, jw |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Can I code HTML code straight to Webbrowser control? | .NET General | |||
| Script-based code sample library (HTA) | VB Script | |||
| Need specific WCF code sample | .NET General | |||
| Efficiency in my sample code | PowerShell | |||