Welcome to Dream.In.Code
Become a VB Expert!

Join 150,138 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,289 people online right now. Registration is fast and FREE... Join Now!




Showing Progress using the ProgressBar Control

 
Reply to this topicStart new topic

Showing Progress using the ProgressBar Control

Ricendithas
13 Jul, 2008 - 03:56 AM
Post #1

New D.I.C Head
*

Joined: 12 Jul, 2008
Posts: 38


My Contributions
Hello there,

I'm creating a program that will connect to a MySQL server online. So, when I try to load the program, it really takes time before all the data will be displayed, in short, it will take few seconds or maybe minutes before the form could be seen. That's why I'm trying to add a progress bar to show progress.

Here is my code for the main form, the one that will connect to the server.

CODE

    Dim CNN As Connection
    Dim rs As Recordset
      
    ' Creating a connection and defining variables.
    Set CNN = New Connection
    CNN.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
                    & "SERVER=" & server & ";" _
                    & "DATABASE=" & database & ";" _
                    & "PORT=" & port & ";" _
                    & "UID=" & user & ";PWD=" & password & ";OPTION=3"
    CNN.Open
    
    ' Connect to the database using this SQL.
    sql = "SELECT * FROM user"
    
    Set rs = New Recordset
    rs.Open sql, CNN
    
    ' Display all the records.
    While (Not rs.EOF)
        List1.AddItem rs.Fields(3) & " " & rs.Fields(4)
        rs.MoveNext
    Wend

    Set rs = Nothing
    CNN.Close


I would like to have another form or maybe a MDI form to display the progress bar.

Hope you can understand.

Thanks. smile.gif
User is offlineProfile CardPM
+Quote Post

tody4me
RE: Showing Progress Using The ProgressBar Control
14 Jul, 2008 - 05:56 AM
Post #2

Only Jenny Craig makes thin clients...
Group Icon

Joined: 12 Apr, 2006
Posts: 1,349



Thanked: 5 times
Dream Kudos: 100
My Contributions
You will need to add the progress bar control somewhere on your form that you want to use. Then you have to have a way of knowing how many records there are to upload (the RecordCount property seems to have this information) and then increment the progress bar.

vb

While (Not rs.EOF)
'Add the variable to the declarations
ctr = ctr + 1
'Add ProgressBar Control to form
ProgressBar1.Value = ctr
List1.Additem rs.Fields(3) & " " & rs.Fields(4)
rs.MoveNext
Wend


This post has been edited by tody4me: 14 Jul, 2008 - 05:56 AM
User is offlineProfile CardPM
+Quote Post

Ricendithas
RE: Showing Progress Using The ProgressBar Control
17 Jul, 2008 - 01:33 AM
Post #3

New D.I.C Head
*

Joined: 12 Jul, 2008
Posts: 38


My Contributions
QUOTE(tody4me @ 14 Jul, 2008 - 06:56 AM) *

You will need to add the progress bar control somewhere on your form that you want to use. Then you have to have a way of knowing how many records there are to upload (the RecordCount property seems to have this information) and then increment the progress bar.

vb

While (Not rs.EOF)
'Add the variable to the declarations
ctr = ctr + 1
'Add ProgressBar Control to form
ProgressBar1.Value = ctr
List1.Additem rs.Fields(3) & " " & rs.Fields(4)
rs.MoveNext
Wend




I tried to follow what you said but there was an error. What is wrong with this?

vb

Set rs = New Recordset
rs.Open sql, CNN

' Set the maximum value for the progress bar.
mdiParent.prgBar.Max = rs.RecordCount

' Display all the records.
While (Not rs.EOF)
ctr = ctr + 1

'Add ProgressBar Control to form
mdiParent.prgBar.Value = ctr

List1.AddItem rs.Fields(3) & " " & rs.Fields(4)
rs.MoveNext
Wend


Thanks.

This post has been edited by Ricendithas: 17 Jul, 2008 - 01:33 AM
User is offlineProfile CardPM
+Quote Post

Ricendithas
RE: Showing Progress Using The ProgressBar Control
19 Jul, 2008 - 05:40 AM
Post #4

New D.I.C Head
*

Joined: 12 Jul, 2008
Posts: 38


My Contributions
I now know how to fix the bug.

vb

Set rs = New Recordset
rs.CursorLocation = adUseClient
rs.Open sql, CNN

' Set the maximum value for the progress bar.
mdiParent.prgBar.Max = rs.RecordCount

' Display all the records.
While (Not rs.EOF)
ctr = ctr + 1

'Add ProgressBar Control to form
mdiParent.prgBar.Value = ctr

List1.AddItem rs.Fields(3) & " " & rs.Fields(4)
rs.MoveNext
Wend

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:09AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month