VB HTML browser 
Author Message
 VB HTML browser

Can someone please help?  I am trying to use the examples in the book
VB 4 Multimedia Adventure Set by Coriolis group and every time VB
tries to read an HTML file I get the error "expecting statement or
end of statement message".  Co-author of book Tony Potts

or fixes.  PlEASE HELP!

Sun, 10 Jan 1999 03:00:00 GMT  
 VB HTML browser

>When I load the program VB immediately reads the first < notation
>in the HTML form and returns the error message "expecting statement
>or end of statement message".

Exactly where in the code is this (which line is highlighted)?

>Private Function LoadHTMLFile(FileName As String) As String


>      [...]
>      ' Read line into temporary string
>      Line Input #Fnum, TempText
>      ' Add line to document string
>      LoadHTMLFile = LoadHTMLFile & TempText


Can you get away with this in VB 4.0 now? Hmm....

VB Info: http://www.sn.no/~balchen/vb/visual.htm
FAQ: http://www.sn.no/~balchen/vb/faq.htm
Knowledge Base: http://www.sn.no/~balchen/vb/kb.htm

Sun, 10 Jan 1999 03:00:00 GMT  
 VB HTML browser

I bought the book Visual Basic 4 Multimedia Adventure Set published
by Coriolis group and co-authored by Scott Jarol and Tony Potts.  The
third exercise in the book builds the multimedia VB engine (the HTML
browser) that is used throughout the rest of the book.  When I load
the program VB immediately reads the first < notation in the HTML
form and returns the error message "expecting statement or end of

able to give me any suggestions or fixes to this problem. PLEASE
Private Function LoadHTMLFile(FileName As String) As String
Dim TempText As String
Dim Fnum As Integer

   LoadHTMLFile = ""
   ' Acquire number for free file
   Fnum = FreeFile
   ' Load HTML contents into string
   Open FileName For Input As #Fnum
   ' Loop until end of file
   Do While Not EOF(Fnum)
      ' Read line into temporary string
      Line Input #Fnum, TempText
      ' Add line to document string
      LoadHTMLFile = LoadHTMLFile & TempText
End Function

here is general process for parsing text
Private Sub ParseHTML(HTML)
Dim TempColor As Long
Dim TempFontSize As Integer
Dim TempUnderline As Boolean
Dim LinkSubject As String
Dim LinkSubjectFile As String
Dim LinkSubjectLink As String
Dim LinkType As String
Dim TagType As String
Dim HRSize As Long

   ' Switch to all uppercase and pull off characters up to
   ' first space. If no spaces, then use whole string.
   If InStr(HTML, Chr$(32)) Then
     TagType = Left(HTML, InStr(HTML, Chr$(32)) - 1)
     TagType = HTML
   End If
   Select Case UCase(TagType)
      Case "BR"             'Line Break
      Case "P", "/P"        'End Paragraph
         If Picture1.CurrentX > 0 Then NewLine
      Case "HR"             'Horizontal Rule
         ' Check for 'SIZE' tag within HTML
         If InStr(UCase(HTML), "SIZE=") Then
            HRSize = Val(Right(HTML, Len(HTML) - InStr(HTML, "SIZE=") - 4))
            HRSize = 1
         End If
         If Picture1.CurrentX > 0 Then NewLine
         TempColor = Picture1.ForeColor ' Store previous
foreground(font) color
         Picture1.ForeColor = vbBlack
         ' Draw horizontal and vertical portions of black section of rectangle
         Picture1.Line (0, (Picture1.CurrentY +
(Picture1.TextHeight("A") / 2)))-(Picture1.ScaleWidth - 1,
(Picture1.CurrentY + (Picture1.TextHeight("A") / 2)))
         Picture1.Line (0, Picture1.CurrentY)-(0, Picture1.CurrentY +
1 + HRSize)
         Picture1.ForeColor = vbWhite
         ' Draw horizontal and vertical portions of white section of rectangle
         Picture1.Line (1, (Picture1.CurrentY))-(Picture1.ScaleWidth,
         Picture1.Line (Picture1.ScaleWidth - 1, Picture1.CurrentY -
HRSize)-(Picture1.ScaleWidth - 1, Picture1.CurrentY)
         Picture1.ForeColor = TempColor ' Reset to old color
         Picture1.CurrentY = Picture1.CurrentY + Picture1.TextHeight("A") / 2
         Picture1.CurrentX = 0
      Case "A"              'Begin Link or Anchor
         ' If there are quotation marks present, then we know
         ' that the link subject is the string between the quotation marks.
         ' Else take everything from the right of the equal sign
         ' up to, but not including, the next space encountered.
         If InStr(HTML, Chr$(34)) Then
            LinkSubject = Right(HTML, ((Len(HTML) - InStr(HTML, Chr$(34)))))
            LinkSubject = Left(LinkSubject, InStr(LinkSubject, Chr$(34)) - 1)
            LinkSubject = Right(HTML, ((Len(HTML) - InStr(HTML, Chr$(61)))))
            If InStr(LinkSubject, Chr$(32)) Then
               LinkSubject = Left(LinkSubject, InStr(LinkSubject,
Chr$(32)) - 1)
            End If
         End If
         ' The link type is the variable before the subject.
         ' So, lets grab the charecters between up to the
         ' equal sign first, then strip off everything up
         ' to the final space.
         LinkType = Left(HTML, InStr(HTML, Chr$(61)) - 1)
         While InStr(LinkType, Chr$(32))
           LinkType = Right(LinkType, ((Len(LinkType) -
InStr(LinkType, Chr$(32)))))
         Select Case LinkType
            Case "HREF"     ' Link
               If Not IsLink Then
                  TempColor = Picture1.ForeColor
                  TempUnderline = Picture1.Font.Underline
                  Picture1.ForeColor = vbBlue
                  Picture1.Font.Underline = True
                  HyperLinkArray(LinkArrayPos).DestinationSubject =
                  HyperLinkArray(LinkArrayPos).Top = Picture1.CurrentY
                  HyperLinkArray(LinkArrayPos).Left = Picture1.CurrentX
                  IsLink = True
               End If
            Case "NAME"     ' Anchor
               AnchorArray(AnchorArrayPos).Name = UCase(LinkSubject)
               AnchorArray(AnchorArrayPos).VPosition = Picture1.CurrentY
               AnchorArrayPos = AnchorArrayPos + 1
         End Select
      Case "/A"             'End link or Anchor
         If IsLink Then
            HyperLinkArray(LinkArrayPos).Bottom = Picture1.CurrentY +
            HyperLinkArray(LinkArrayPos).Right = Picture1.CurrentX
            LinkArrayPos = LinkArrayPos + 1
            Picture1.ForeColor = TempColor
            Picture1.Font.Underline = TempUnderline
            IsLink = False
         End If
      Case "/H1", "/H2", "/H3", _
           "/H4", "/H5", "/H6" 'Headings Off
         If Picture1.CurrentX > 0 Then NewLine
         Picture1.Font.Size = 12
      Case "H1"             'Heading 1
         If Picture1.CurrentX > 0 Then NewLine
         Picture1.Font.Size = 30
      Case "H2"             'Heading 2
         If Picture1.CurrentX > 0 Then NewLine
         Picture1.Font.Size = 24
      Case "H3"             'Heading 3
         If Picture1.CurrentX > 0 Then NewLine
         Picture1.Font.Size = 20
      Case "H4"             'Heading 4
         If Picture1.CurrentX > 0 Then NewLine
         Picture1.Font.Size = 16
      Case "H5"             'Heading 5
         If Picture1.CurrentX > 0 Then NewLine
         Picture1.Font.Size = 10
      Case "H6"             'Heading 6
         If Picture1.CurrentX > 0 Then NewLine
         Picture1.Font.Size = 8
      Case "EM"             'Bold On
         Picture1.Font.Bold = True
         Picture1.Font.Italic = True
      Case "/EM"            'Bold Off
         Picture1.Font.Bold = False
         Picture1.Font.Italic = False
      Case "B", "STRONG"    'Bold On
         Picture1.Font.Bold = True
      Case "/B", "/STRONG"  'Bold Off
         Picture1.Font.Bold = False
      Case "U"              'Underline On
         Picture1.Font.Underline = True
      Case "/U"             'Underline Off
         Picture1.Font.Underline = False
      Case "I", "CITE"      'Italic On
         Picture1.Font.Italic = True
      Case "/I", "/CITE"    'Italic Off
         Picture1.Font.Italic = False
      Case "PRE"            'Exact Text On
         Picture1.Font = "Courier New"
         PreFormat = True
      Case "/PRE"           'Exact Text Off
         Picture1.Font = "Times New Roman"
         PreFormat = False
      Case "TT"             'Typewriter Text On
         Picture1.Font = "Courier New"
      Case "/TT"            'Typewriter Text Off
         Picture1.Font = "Times New Roman"
   End Select
End Sub

Here is general declarations
Option Explicit

Dim HyperLinkArray(500) As HyperLinkElement
Dim AnchorArray(500) As AnchorElement
Dim LinkArrayPos As Integer
Dim AnchorArrayPos As Integer
Dim IsLink As Boolean
Dim Text As String
Dim PreFormat As Boolean


Sun, 10 Jan 1999 03:00:00 GMT  
 VB HTML browser

I try to install VB4 under WIN-95, but I could not get 32-bit
version working. The instllation told me that it's a 100%
successful install, but when I run, it came up with the following

VB32 caused an invalid page fault in
module KERNEL32.DLL at 014f:bff858cd.
EAX=c0020ecc CS=014f EIP=bff858cd EFLGS=00010202
EBX=0073fe28 SS=0157 ESP=0063ffe0 EBP=00640050
ECX=8155e300 DS=0157 ESI=81568bc8 FS=0e2f
EDX=c0020ed0 ES=0157 EDI=8155e344 GS=0000
Bytes at CS:EIP:
53 56 89 4d f8 57 8b 41 40 8b 75 08 89 45 ec 83
Stack dump:

When I closed program, and tried again, it came up with a
different message.

VB32 caused an invalid page fault in
module VB32.EXE at 014f:0042226b.
EAX=00c70fb8 CS=014f EIP=0042226b EFLGS=00010206
EBX=0073f76c SS=0157 ESP=0073f6f4 EBP=0073f718
ECX=c1071444 DS=0157 ESI=00000000 FS=0e17
EDX=00000000 ES=0157 EDI=004c602c GS=0000
Bytes at CS:EIP:
8b 30 ff 56 08 5e c3 56 8b f1 e8 51 00 00 00 f6
Stack dump:
00c70fb8 bff8bb98 0040e0e7 0073f720 00000082 004058c6 0073f720
00008790 0073f76c 0073f738 bff73663 000004cc 00000082 00000000
00000000 876a0e0f

Subsequent run all produced the same error message. But if I
restart win, it would produce the first message again, then
the second one and so on....

Why is that?? any help is appreciated.

by the way, I did get 16-bit version working; and the Vb i have
is quite old, check properities produce
Date stamped on 8th Nov.94


Mon, 11 Jan 1999 03:00:00 GMT  
 [ 5 post ] 

 Relevant Pages 

1. VB HTML browser

2. Opening HTML file in IE browser from VB 5.0 Application

3. HTML browser in VB program

4. Using VB to control Netscape as a Browser for HTML-files on disk

5. How to view HTML doc on VB form, not in the Browser

6. Call VB routine from HTML in web Browser control

7. How to view the HTML Source using VB 4 and the Web Browser Control

8. Web Browser control for viewing HTML text within a vb app

9. Opening HTML file in IE browser from VB 5.0 Application

10. Display HTML Document in Browser

11. HTML source file is not the same on equal browsers

12. view HTML page source in browser - vbscript method?


Powered by phpBB® Forum Software