This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-04-20 07:44:37

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Need Visual Basic Help!

I have this code for a tabbed web browser:

Code:

Public Class Form1
    Dim i As Integer = 1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim Browse As New WebBrowser
        TabControl1.TabPages.Add(1, "TEST")
        TabControl1.SelectTab(i - 1)
        Browse.Name = "wb"
        Browse.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browse)
        i = i + 1
    End Sub
End Class

But there isn't a new tab page! No errors, though...


http://i46.tinypic.com/dw7zft.png

Offline

 

#2 2011-04-20 07:54:41

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Bump  sad


http://i46.tinypic.com/dw7zft.png

Offline

 

#3 2011-04-20 07:59:38

rabbit1131
Scratcher
Registered: 2009-10-16
Posts: 1000+

Re: Need Visual Basic Help!

I'll get math.... Wait for a few minutes...


The Intergalactic Adventures of Revesilia! I hope you will partake in this gigantic undertaking, to build the sequel to the hit map The Adventures of Revesilia! The Intergalactic Adventures of Revesilia Map Builders Application thread! http://internetometer.com/image/35004.png

Offline

 

#4 2011-04-20 09:06:56

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Need Visual Basic Help!

Your problem is that TabPages is a read-only property, therefore when you add an object to it it doesn't reflect that change in the Tab Control. I'll see if I can find a solution.


/* No comment */

Offline

 

#5 2011-04-20 16:30:24

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

TheSuccessor wrote:

Your problem is that TabPages is a read-only property, therefore when you add an object to it it doesn't reflect that change in the Tab Control. I'll see if I can find a solution.

Actually, no. I hooked up the same code to a button, and it worked fine.


http://i46.tinypic.com/dw7zft.png

Offline

 

#6 2011-04-20 16:55:28

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

BuMpInG


http://i46.tinypic.com/dw7zft.png

Offline

 

#7 2011-04-20 17:23:36

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Bump  sad


http://i46.tinypic.com/dw7zft.png

Offline

 

#8 2011-04-20 19:00:48

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: Need Visual Basic Help!

SeptimusHeap wrote:

Bump  sad

Mine works just look for differences.

Mine. (This works)

TabControl1.Visible = True
        Dim newpage As New WebBrowser

        TabControl1.TabPages.Add(1, "blank")
        TabControl1.SelectTab(i)
        newpage.Name = "wb"
        newpage.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(newpage)
        i = i + 1



Yours.

Dim Browse As New WebBrowser
        TabControl1.TabPages.Add(1, "TEST")
        TabControl1.SelectTab(i - 1)
        Browse.Name = "wb"
        Browse.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browse)
        i = i + 1


When you add the tab control to your page make sure you remove one of the tabs. The default is two but you are initalizing it as having one.

Last edited by what-the (2011-04-20 19:07:56)


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#9 2011-04-20 19:11:41

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

what-the wrote:

SeptimusHeap wrote:

Bump  sad

Mine works just look for differences.

Mine. (This works)

TabControl1.Visible = True
        Dim newpage As New WebBrowser

        TabControl1.TabPages.Add(1, "blank")
        TabControl1.SelectTab(i)
        newpage.Name = "wb"
        newpage.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(newpage)
        i = i + 1



Yours.

Dim Browse As New WebBrowser
        TabControl1.TabPages.Add(1, "TEST")
        TabControl1.SelectTab(i - 1)
        Browse.Name = "wb"
        Browse.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browse)
        i = i + 1


When you add the tab control to your page make sure you remove one of the tabs. The default is two but you are initalizing it as having one.

Still doesn't work. I have a tabcontrol with 1 tab.


http://i46.tinypic.com/dw7zft.png

Offline

 

#10 2011-04-20 19:17:32

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Oh, and it's in a splitter thing.

http://img844.imageshack.us/img844/5168/40940488.png


http://i46.tinypic.com/dw7zft.png

Offline

 

#11 2011-04-20 19:28:38

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: Need Visual Basic Help!

Tell me what happens when you debug. Is any thing highlighted in red, yellow or green?


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#12 2011-04-20 19:29:41

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

what-the wrote:

Tell me what happens when you debug. Is any thing highlighted in red, yellow or green?

Oddly, no.


http://i46.tinypic.com/dw7zft.png

Offline

 

#13 2011-04-20 19:30:45

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Here: DOWNLOAD


http://i46.tinypic.com/dw7zft.png

Offline

 

#14 2011-04-20 19:39:58

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: Need Visual Basic Help!

Dim Browse As New WebBrowser
        TabControl1.TabPages.Add(1, "TEST")
        TabControl1.SelectTab(i)
        Browse.Name = "wb"
        Browse.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browse)
        Browse.Navigate("http://scratch.mit.edu")
        i = i + 1

Did you tell the browser to navigate. Copy the above code and see if it works.




Look at "TabControl1.SelectTab(i)"
You have it as TabControl1.SelectTab(i -1)

This is one of the problems. It is making a new browser on top of the old one.
If you want it to switch back to the original tab after making using a variable place holder.

  Dim originaltab As Integer = 1
        originaltab = TabControl1.SelectedIndex
        Dim Browse As New WebBrowser
        TabControl1.TabPages.Add(1, "TEST")
        TabControl1.SelectTab(i)
        Browse.Name = "wb"
        Browse.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browse)
        Browse.Navigate("http://scratch.mit.edu")
        i = i + 1
       
        TabControl1.SelectTab(originaltab)

Last edited by what-the (2011-04-20 19:45:16)


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#15 2011-04-20 19:43:53

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Still no. The new tab doesn't show up D: try messing wiht my code.


http://i46.tinypic.com/dw7zft.png

Offline

 

#16 2011-04-20 19:46:45

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: Need Visual Basic Help!

SeptimusHeap wrote:

Still no. The new tab doesn't show up D: try messing wiht my code.

Your code works when I get ride of the  - 1


http://img94.imageshack.us/img94/6553/ddfdas.png
This is your original code. (Note the browser for teh second tab won't be made because the -1 is still there.

Last edited by what-the (2011-04-20 19:50:50)


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#17 2011-04-20 19:47:18

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

what-the wrote:

SeptimusHeap wrote:

Still no. The new tab doesn't show up D: try messing wiht my code.

Your code works when I get ride of the  - 1

?


http://i46.tinypic.com/dw7zft.png

Offline

 

#18 2011-04-20 19:50:01

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

SeptimusHeap wrote:

what-the wrote:

SeptimusHeap wrote:

Still no. The new tab doesn't show up D: try messing wiht my code.

Your code works when I get ride of the  - 1

?

This is my current code:

Public Class Form1
    Dim i As Integer = 1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim originaltab As Integer = 1
        originaltab = TabControl1.SelectedIndex
        Dim Browse As New WebBrowser
        TabControl1.TabPages.Add(1, "TEST")
        TabControl1.SelectTab(i)
        Browse.Name = "wb"
        Browse.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browse)
        Browse.Navigate("http://scratch.mit.edu")
        i = i + 1

        TabControl1.SelectTab(originaltab)
    End Sub

   

    Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
        SplitContainer1.Height = Me.Height - 24
        SplitContainer1.Width = Me.Width
        SplitContainer1.SplitterDistance = 175
    End Sub
End Class

With no current open tabs.


http://i46.tinypic.com/dw7zft.png

Offline

 

#19 2011-04-20 19:55:07

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: Need Visual Basic Help!

Now I see.


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#20 2011-04-20 19:57:56

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: Need Visual Basic Help!

LOL lol lol lol LOL lol lol lol LOL lol lol lol

Add this to the form load; "Handles MyBase.Load".

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#21 2011-04-20 20:01:24

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Yes


http://i46.tinypic.com/dw7zft.png

Offline

 

#22 2011-04-20 20:20:28

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Erm, is there a possible way to add a close button on each tab without heaps of code?


http://i46.tinypic.com/dw7zft.png

Offline

 

#23 2011-04-20 20:47:18

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Bump


http://i46.tinypic.com/dw7zft.png

Offline

 

#24 2011-04-21 07:18:04

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Need Visual Basic Help!

Bump


http://i46.tinypic.com/dw7zft.png

Offline

 

#25 2011-04-21 09:47:03

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Need Visual Basic Help!

SeptimusHeap wrote:

TheSuccessor wrote:

Your problem is that TabPages is a read-only property, therefore when you add an object to it it doesn't reflect that change in the Tab Control. I'll see if I can find a solution.

Actually, no. I hooked up the same code to a button, and it worked fine.

I think I might have a different version of VB, looking at the further posts...


/* No comment */

Offline

 

Board footer