Results 1 to 6 of 6

Thread: Progress Bar Code

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    13

    Progress Bar Code

    Hey, Im a new user of VB6 and im having some trouble figuring out the code needed for my progress bar to work. Here is the scenario. I have created a log in interface where a message box will show up after the login command button is clicked. What i want to do is show the progress bar gradually advancing after the login command button is clicked after which i want the message box to show up. My reason for this is to make it seem to the user that the program is searching to see if the username & password is correct. I have searched all over the internet for this code that im sure is very simple but my attempts were futile. Could i get help to do this? Thanx

  2. #2
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Progress Bar Code

    Sample.

    Code:
    Private Sub Command1_Click()
        'assuming that the login is successful
        MsgBox "Login Successful"
        ProgressBar1.Value = 1
        
        MsgBox "DONE"
        'just add the value up to 2 to make it 100%
        ProgressBar1.Value = 2
    End Sub
    
    Private Sub Form_Load()
        ProgressBar1.Min = 0
        'max is 2
        ProgressBar1.Max = 2
    End Sub

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Progress Bar Code

    Another kind of simple progress display. Or, more likely, "something is happening" bar.

    Edit!
    Including here a poor man's sample: add Picture1, Label1 into Picture1 and a Timer1 to a new project. Paste this code:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Picture1.ScaleMode = vbPixels
        Picture1.BackColor = vbHighlightText
        Label1.BackColor = vbHighlight
        Label1.Caption = vbNullString
        Label1.Move -100, 0, 100, Picture1.ScaleHeight
        Timer1.Interval = 1
    End Sub
    
    Private Sub Timer1_Timer()
        If Label1.Left <= Picture1.ScaleWidth Then
            Label1.Left = Label1.Left + 5
        Else
            Label1.Left = -100
        End If
    End Sub
    Last edited by Merri; Apr 10th, 2007 at 07:59 AM.

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    13

    Re: Progress Bar Code

    Still expiencing a problem Zynder. When i click login & the message box shows up the progress bar stops half way. & it goes really fast, like a blink of the eye. Is there anyway to slow down the loading illusion of the process bar? Here is my codes:


    Private Sub cmdlogin_Click()

    If txtusername.Text = "iron" And txtpassword.Text = "evolution" Then
    ProgressBar1.Value = 1

    MsgBox ("Welcome to Iron's Sports and Luxary Car Rental"), vbInformation, ("Iron's Car Rental")
    ProgressBar1.Value = 2
    Else
    If txtusername.Text <> "iron" And txtpassword.Text = "evolution" Then
    MsgBox ("Invalid Username! Please Try Again"), vbCritical, ("RJ's Car Rental")
    Else
    If txtusername.Text = "iron" And txtpassword.Text <> "evolution" Then
    MsgBox ("Invalid Password! Please Try Again"), vbCritical, ("RJ's Car Rental")
    Else
    If txtusername.Text <> "iron" And txtpassword <> "evolution" Then
    MsgBox ("Invalid Username and Password! Please Try Again"), vbCritical, ("RJ's Car Rental")


    End If
    End If
    End If

    End If

    End Sub




    Private Sub Label4_Click()
    MsgBox ("View the Readme file in the project folder"), vbInformation, ("Forgot your Password?")
    End Sub

    Private Sub Form_Load()
    ProgressBar1.Min = 0
    'max is 2
    ProgressBar1.Max = 2
    End Sub
    Last edited by Ironman; Apr 9th, 2007 at 11:18 PM.

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Progress Bar Code

    Since you can't really calculate a real loading progress in this case, you could try the solution to which I linked to. It is a progress bar that only shows something is happening. You've probably seen this same kind of progress bar being used by Microsoft: just a bar of a fixed size passes by the progress area.

    You also don't want to store usernames and passwords directly readable anywhere in the source code.

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    13

    Re: Progress Bar Code

    Thanx Merri, ill make that do. Ill give u some ratings for ur assistance. By the way, do u have a hotmail address? Maybe we can chat more often. & to Zynder if u read this, id like to have ur email address. Hope 2 talk 2 u soon. Thanx 4 the help

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