There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers dvd error excel external hard drive firefox format freezes freezing hard drive hardware hijackthis internet internet explorer ipod itunes laptop malware mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan upgrade usb virus vista vista 32-bit windows windows xp winxp wireless
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
vb6 WebBrowser control


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
booknet's Avatar
Junior Member with 2 posts.
 
Join Date: Sep 2004
14-Sep-2004, 02:20 AM #1
vb6 WebBrowser control
I use the following Code to find string in A HTMl in WebBrowser control, but
if HTML support Frame then I get the error (run-time error "438"). any idea
how to fix this error.
Thanks,
Harry

Code:
      Public myfindFirst As Boolean
      Public oRange

Private Sub cmdFind_Click()
    Dim sSearch As String
    If myfindFirst Then
        Set oRange = WebBrowser1.Document.body.createTextRange
        sSearch = txtFind.Text
        If oRange.FindText(sSearch) Then
          oRange.Select
          oRange.scrollIntoView
          cmdFind.Caption = "Find Next"

          myfindFirst = False
        Else
         MsgBox ("Search string " & txtFind.Text & " not found.")
        End If
    Else
        Call oRange.Move("character")
        sSearch = txtFind.Text
        If oRange.FindText(sSearch) Then
            oRange.Select
            oRange.scrollIntoView
        Else
            MsgBox ("Finished searching Document for string " & 
txtFind.Text)
            cmdFind.Caption = "Find"
            myfindFirst = True
            Exit Sub
        End If
    End If

End Sub
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
15-Sep-2004, 11:02 PM #2
If you are working with frames there is no document.body


To test for the presence of frames:
Code:
Private Sub Command3_Click()
Set frames = WebBrowser1.Document.getElementsByTagName("frame")
  
If frames.length > 0 Then 'If there are frames
 For Each Frame In frames
   List1.AddItem Frame.LocationURL
 Next
End If
End Sub
This example will get you the url for each frame and add them to a list box.

Otherwise execute the other code.
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
16-Sep-2004, 02:13 AM #3
Here's something else to play with. This will put the html code of all frames for the currently loaded WebBrowser Document into a text box. You can use a variable or whatever.

Code:
Private Sub Command4_Click()
Dim Cont As Object
Dim sBody As String, k As Integer

For k = 0 To WebBrowser1.Document.frames.length - 1 

Set Cont = WebBrowser1.Document.frames(k).Document
sBody = Cont.body.innerHTML ' or use innerTEXT  if you prefer.
Text1.Text = Text1.Text & "NEXT" & vbCrLf & sBody & vbCrLf & vbCrLf & vbCrLf 
Next
End Sub

Last edited by Mosaic1 : 16-Sep-2004 02:21 AM.
booknet's Avatar
Junior Member with 2 posts.
 
Join Date: Sep 2004
18-Sep-2004, 06:13 PM #4
yes, but how can I use these code to find A special text in webbrowser document (support Frame)?
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
18-Sep-2004, 09:22 PM #5
See if you can work with this instead. I haven't tried to find a string inside a frame. Search one frame at a time.

Code:
Dim range As Object
Dim k as Integer
  
  For k = 0 To WebBrowser1.Document.frames.length - 1

   Set range = WebBrowser1.Document.frames(k).Document.body.createTextRange


Add Search code.

Next

Last edited by Mosaic1 : 18-Sep-2004 09:41 PM.
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
18-Sep-2004, 09:44 PM #6
Or you could set something up to search only selected frames.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:02 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.