0

I started to code a program in VB6 only because I knew the language well and how to work with it. I unfortunately ran into some snags since it's an older program, and now I'm learning the more recent version of it (2010) but have a question:

How do I create more instances of WebBrowser in this latest version? This is my code from VB6 to help you get an idea of what I mean:

If Not AdBrowser(URLs.ListIndex + 1) Then
    'For i = 1 To URLs.ListCount - 1
    Load AdBrowser(URLs.ListIndex + 1)
    'Next i
    AdBrowser(URLs.ListIndex + 1).Left = 120
    AdBrowser(URLs.ListIndex + 1).Top = 240
    AdBrowser(URLs.ListIndex + 1).Height = 7695
    AdBrowser(URLs.ListIndex + 1).Width = 15975
End If

Basically what the code is doing is when someone clicks on the list box, it creates a new instance of AdBrowser and keeps the Array # the same index as the list index. I need similar code that will do the same thing in the latest VB..

I know you can't do the same thing as before and I've looked it up on Google with a couple different variations and still nothing. I've found stuff related to creating control arrays which is basically what I'm doing here, but nothing that would work with WebBrowser control.

New question!

Now I'm having troubles finding a way to check if the browser is already loaded, this is my code that isn't working but has the right idea:

For i = 0 To BrowserArray.Count
        BrowserArray(i).Visible = False
    Next
    If Not BrowserArray(URLs.SelectedIndex) Then

    Else
        BrowserArray = New AdBrowserArray(Me)
        BrowserArray.AddNewBrowser(MainFrame)
        BrowserArray(URLs.SelectedIndex).Navigate("http://google.com")
    End If
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Jimmy
  • 1
  • 2

1 Answers1

0

Controls can be used in an array just like any other object.

Have a look at the following SO questions regarding control arrays in VB.NET:

Control Arrays in .NET

Creating control from 'control array?'

You should be able to use the webbrowser just like any other control so maybe post some .NET code so we can have a look whats wrong

Community
  • 1
  • 1
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • Ok so I did find some working code on Microsoft's dev website, but now i'm running into a problem where i'm not sure how to check if the control already exists and not to load a new one if it doesn't have to. i will paste the code above so you can see it better. – Jimmy Oct 05 '11 at 19:22