Results 1 to 2 of 2

Thread: Help with Trackbar in VB 2008

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    1

    Help with Trackbar in VB 2008

    Hi im new to this so please bere with me.

    Im trying to get a trackbar to work so that when it slides if enables the visible setting of some list boxes and lables etc.

    When trackbar = 5, listboxes 1-5 are displayed, lables 1-5 are displayed and buttons 1-5 are displayed but 6-8 are all hidden.
    Similally when trackbar = 2, listboxes 1 and 2 are displayed, lables 1 and 2 are displayed and buttons 1 and 2 are displayed but 3-8 are all hidden.

    Ive got it to work but only after 200 odd lines of code with loads of if statements and to be honest im sure it can be done in a better way.

    If anyone can help I would really appreciate it.

    Bellow is some of what I have currently got.

    If trackbarvalue = 8 Then
    lstIsle8.Visible = True
    lblShelf8.Visible = True
    btnAddShelf8.Visible = True
    btnAddList8.Visible = True
    lstIsle7.Visible = True
    lblShelf7.Visible = True
    btnAddShelf7.Visible = True
    btnAddList7.Visible = True

    etc etc.

    Thanks very much in anticipation

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: Help with Trackbar in VB 2008

    You can do this in a more compact way.

    In the trackbar changed event, use 'logic' for each control you want to display. Here's what I mean by that;

    Code:
        Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles TrackBar1.Scroll
    
            TextBox1.Visible = TrackBar1.Value <= 5
    
            Label1.Visible = TrackBar1.Value > 3 And TrackBar1.Value < 8
            'etc
    
        End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width