6 Replies - 352 Views - Last Post: 26 July 2012 - 07:38 AM Rate Topic: -----

#1 eye55  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 23-July 12

self teaching VB.net Select case question.

Posted 23 July 2012 - 05:13 PM

I am self teaching myself VB.net. I purchased a book online and one of the codes it is telling me to write is a select case for a tool bar but with vb 2008 it does not accept .Buttons.IndexOf(e.Button) What would I use instead? below is the code book is telling me to write.


 Select Case tbrMainToolbar.Buttons.IndexOf (e.Button)
          Case is = 0
             Me.Close()
          Case is = 1
             txtMyTextbox.Visible = Not (tbbInvisible.Pushed)


I have also tried to use an if then statement on just the button I am writing code for but I can get it to disappear with the toggle button but not reappear. Any help with converting the Select case to work with VB 2008 or If then statement would be greatly appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: self teaching VB.net Select case question.

#2 eye55  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 23-July 12

Re: self teaching VB.net Select case question.

Posted 23 July 2012 - 05:54 PM

Ok I was able to get the if then statement working

 if tbbInvisible.checked = true then
                   Txtbox.visible = true
              End if
              If tbbInvisible.checked = false then 
                     Txtbox.visible= false
               End if.  

Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 549
  • View blog
  • Posts: 2,911
  • Joined: 19-May 09

Re: self teaching VB.net Select case question.

Posted 23 July 2012 - 06:09 PM

What's the error you were getting when you tried to use select case? Also, you can do this:
TxtBox.Visible = tbbInvisible.Checked
which means that you're setting the visible property of txtbox to equal the checked property of tbbInvisible. However, that's not what the first code example is doing exactly.
Was This Post Helpful? 1
  • +
  • -

#4 eye55  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 23-July 12

Re: self teaching VB.net Select case question.

Posted 23 July 2012 - 06:30 PM

with the select case debugger was giving me
Error 1 'buttons' is not a member of 'System.Windows.Forms.ToolStrip'.
Error 2 'button' is not a member of 'System.Windows.Forms.ToolStripItemClickedEventArgs'.
Error 3 'Pushed' is not a member of 'System.Windows.Forms.ToolStripButton'.

The issue is I am using newer visual basic. In the book it says to create a toolbar but on the version I am using it has a toolstrip. I was just wondering if there was some way of doing the same thing as the tool bar with the toolstrip. What they are asking is to set all the buttons code up on the toolbar with Button_click event. When I try to do it with the same code as the toolbar it gives me the errors above. Doing some research online I have found that it is better to set up each buttons code individually but out of curiosity I was wondering if I could get the same results with the toolstrip (as in all the code under the toolstrip and not under each individual button).
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 549
  • View blog
  • Posts: 2,911
  • Joined: 19-May 09

Re: self teaching VB.net Select case question.

Posted 23 July 2012 - 06:54 PM

That must be a very old book! Tool strips have been around since .Net 2.0, which shipped in 1994 if I'm not mistaken. I'd suggest that you read a couple of tutorials on the Toolstrip control, and set one up in a form. It's not difficult. Then incorporate what you've learned into your app that you're doing with your book.

FYI, the ToolStrip object has an Items property which is a collection of all the items on the bar. You use the ItemClicked event of the toolstrip and then figure out which item was clicked.
Was This Post Helpful? 1
  • +
  • -

#6 eye55  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 23-July 12

Re: self teaching VB.net Select case question.

Posted 24 July 2012 - 04:05 AM

Thank you for your assistance and the quick responses. The book was actually first published in 2001. Maybe it took the author that long to write it that he fell behind on the current versions of vb. I have only been reading it for a couple of days now so there is plenty I still need to learn. after I finish it I will go into more specific tutorials.
Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 549
  • View blog
  • Posts: 2,911
  • Joined: 19-May 09

Re: self teaching VB.net Select case question.

Posted 26 July 2012 - 07:38 AM

It probably doesn't cover .Net 2.0, and the latest version is 4.0. It's like using a book on Windows XP to try to learn Windows 7. I'd consider working with something more current.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1