Results 1 to 7 of 7

Thread: porobably a silly question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    UK
    Posts
    204

    Question porobably a silly question

    i have just tried adding a Progress bar to my project everythings ok but i need help on hiding it

    i tried this

    Private Sub pro_Click()
    If pro.Caption = "Hide Progress Bar" Then GoTo 1 Else
    If pro.Caption = "Show Progress Bar" Then GoTo 2

    1: ProgressBar1.Visible = False
    pro.Caption = "Show Progress Bar"

    2: ProgressBar1.Visible = True
    pro.Caption = "Hide Progress Bar"
    End Sub

    i think it needs some kind of end in between 1 and 2 because it does both, can someone help me out?

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    You need to put an Exit Sub before the second go to label. But, you should just lose goTo.
    VB Code:
    1. Private Sub pro_Click()
    2.     If pro.Caption = "Hide Progress Bar" Then
    3.         ProgressBar1.Visible = False
    4.         pro.Caption = "Show Progress Bar"
    5.     ElseIf pro.Caption = "Show Progress Bar" Then
    6.         ProgressBar1.Visible = True
    7.         pro.Caption = "Hide Progress Bar"
    8.     End If
    9. End Sub

  3. #3
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067
    Do this instead.

    Private Sub pro_Click()

    If pro.Caption = "Hide Progress Bar" Then
    ProgressBar1.Visible = False
    pro.Caption = "Show Progress Bar"
    Else
    ProgressBar1.Visible = True
    pro.Caption = "Hide Progress Bar"
    End if

    End Sub

    Mega.
    "If at first you don't succeed, then skydiving is not for you"

  4. #4
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067

    Angry

    Cross posted again.. ARGH!!!!.. Every time.
    "If at first you don't succeed, then skydiving is not for you"

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    UK
    Posts
    204

    Smile Thanks!

    Thanks guys!!

  6. #6
    New Member
    Join Date
    Jun 2001
    Location
    Italy
    Posts
    14

    Wink

    Also:

    Insert EXIT SUB between lin1 1. an d 2.

    Private Sub pro_Click()
    If pro.Caption = "Hide Progress Bar" Then GoTo 1 Else
    If pro.Caption = "Show Progress Bar" Then GoTo 2

    1: ProgressBar1.Visible = False
    pro.Caption = "Show Progress Bar"
    EXIT SUB
    2: ProgressBar1.Visible = True
    pro.Caption = "Hide Progress Bar"
    End Sub

  7. #7
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Originally posted by alip1
    Also:
    Insert EXIT SUB between lin1 1. an d 2.
    Nooooooooooooooooooooooooooo
    Don't use goto's at all. The only times they should be used are in error handling (On Error Goto...) and maybe if the number of nested If Then's is too great.
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

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