Determine number of tabs in Tabcontrol in 'If' statement

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

34 Replies - 1955 Views - Last Post: 24 February 2012 - 12:54 PM Rate Topic: -----

#1 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 09:36 AM

Hello.
I am writing a tabbed webbrower program and i am trying to close the program when all tabs have been closed using ctrl+w. So far i have used the following code but it has errors as tabcount is readonly:
If
            TabControl1.TabCount.Equals(0) then
            Me.Close()
        End If

Please help.
Thanks in advance.
Is This A Good Question/Topic? 0
  • +

Replies To: Determine number of tabs in Tabcontrol in 'If' statement

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 09:38 AM

With that snippet you are only getting the value and not setting it anyways so what exactly is the error you are getting?
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 09:40 AM

** Moved to VB.NET **
The advanced sub-forum is not for errors in code, it's for discussion of programing methods & ideas. Please feel free to private message me if you are not understanding the structure of the subforums.
Was This Post Helpful? 0
  • +
  • -

#4 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 09:41 AM

Sorry. I didn't set it out correctly!
I have fixed that but it doesn't work. It doesn't show an error either. It basicly ignores it. Does anybody know why?

This post has been edited by curlyfries1999: 19 February 2012 - 09:49 AM

Was This Post Helpful? 0
  • +
  • -

#5 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 09:46 AM

We need to know the exact error you are getting, tell us what error(exactly statements) and at which line it happens.

Also what if you say:
	If TabControl1.TabCount = 0 Then
   Application.Exit()

Because Me.Close() will not exit the whole app if there are other forms hidden/ open
Was This Post Helpful? 0
  • +
  • -

#6 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 09:54 AM

That code doesn't work either.
Was This Post Helpful? 0
  • +
  • -

#7 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 09:55 AM

View Postsmohd, on 19 February 2012 - 11:46 AM, said:

We need to know the exact error you are getting

I don't see where you have answered this question. Please provide as much detail as you can.
Was This Post Helpful? 0
  • +
  • -

#8 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 10:00 AM

View Postno2pencil, on 19 February 2012 - 09:55 AM, said:

View Postsmohd, on 19 February 2012 - 11:46 AM, said:

We need to know the exact error you are getting

I don't see where you have answered this question. Please provide as much detail as you can.

They are actually trying to help!
Was This Post Helpful? 0
  • +
  • -

#9 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 10:04 AM

View Postcurlyfries1999, on 19 February 2012 - 12:00 PM, said:

View Postno2pencil, on 19 February 2012 - 09:55 AM, said:

View Postsmohd, on 19 February 2012 - 11:46 AM, said:

We need to know the exact error you are getting

I don't see where you have answered this question. Please provide as much detail as you can.

They are actually trying to help!

No doubt about that.

But replies like "That code doesn't work either." just says your copy & pasting their code, hoping for a quick, turn-key solution. Please answer the requests for error messages.
Was This Post Helpful? 1
  • +
  • -

#10 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 10:08 AM

There was no error. When i ran the code it did exactly the same as when that code wasn't there.
Was This Post Helpful? 0
  • +
  • -

#11 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 10:15 AM

Now if you have fixed the previous means you have updated your code, please post the updated code- the full code for the sub.
Without seeing your logic it will be harder to help, because to me it gives logic that when TabCount = 1 is the time to close the whole application. So post the complete sub and if you call it anywhere
Was This Post Helpful? 0
  • +
  • -

#12 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 10:28 AM

I would like it so when all tabs have been closed the application closes. Like in firefox, when you close the last tab the application closes. Press ctrl+w until all of the tabs have closed to see what i mean.

This post has been edited by curlyfries1999: 19 February 2012 - 10:32 AM

Was This Post Helpful? 0
  • +
  • -

#13 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 10:32 AM

So where does this code reside? Is it in an event where you can determine the number of open tabs each time a tab closes?
Was This Post Helpful? 0
  • +
  • -

#14 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 10:33 AM

I have found the problem. I put it in a timer sub but forgot to start it. Stupid or what?!

This post has been edited by curlyfries1999: 19 February 2012 - 10:33 AM

Was This Post Helpful? 0
  • +
  • -

#15 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Determine number of tabs in Tabcontrol in 'If' statement

Posted 19 February 2012 - 11:14 AM

What's the timer for? I hope you haven't set up a timer to tick every millisecond to check whether every tab has been closed, as that is an horrific waste of system resources.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3