hello to everyone! is there any one can help me to associate the progress bar with the loading application? such that if it finished executing, the progress bar also finished loading.. thanks! i am grateful for the responses. God bless you all!

Well, Arvin2006, it all depends on the application in question, and the code in its Form_Load or Sub Main (depending on which you use to load the application). I'm assuming you mean a progress bar on something like a splash screen.

The trick to setting up a progress bar to indicate how much of an application has loaded is to divide the code which loads the application into distinct parts. From there, you can decide how much to increment the progress bar as each part completes.

For example, suppose I have an application that loads in four parts: reading in registry values, loading one or more plugins, initializing variables and objects, and arranging/displaying the interface. I know that the parts that will take the longest are the second and third, and that they will take much longer than the other two parts to complete, so I decide not to make the progress bar range from 0 units to 4 and have each part worth 1unit - which would make each part fill 1/4 of the progress bar. Instead, I will assign the first and last parts a value of 1 unit each, and the second part a value equal to the humber of plugins I have to load.

For the third part, I will have to do some guessing and estimation. How long will it take to initialize each variable? How long will it take to create and initialize each object? What portion of the entire load time will each variable and object take up? Based on that information, I divide my variables and objects into smaller groups, and assign each group a value of 1. The progress bar now ranges from 0 to 2 + the number of plugins + the number of variable/object groups.

Now, I add a bit of code to my loading process which will bump the progress bar up by 1: after part one finishes, after each plugin is loaded, after each variable/object group is initialized, and after part four is finished. The splash screen with the progress bar on it is set up to unload itself when the progress bar reaches its maximum value.

Of course, the way you break up your progress bar is entirely up to you, and will vary from program to program. But hopefully this gives you an idea of what you need to do to pull this off. Good luck, and enjoy!

- Sendoshin

thanks for the response.. i appreciate it very much. but i dont know how can it be done.. if i will estimate the total loading timeof the application is approximately less than 1 minute. i tried to set 1 minute for the progress bar, but the problem is this: the application will only start loading after the progress bar finished loading, if i will set them at same time (formloadbar.show and "open.exe") the progress bar will be interrupted and not continue loading.. how could i know the part that has been loaded in the application(for example, an executable program like games,etc..) can you pls give me some idea regarding this.. thank you so much!! God bless.

Increment the progress bar in the code that actually loads the program, then call DoEvents to refresh the progress bar's display. For the example I gave above:

Load frmProgress
With frmProgress.ProgressBar1
.Max = <number of progress bar parts>
.Value = 0

<read in registry values>
 .Value = .Value + 1
DoEvents

<for each plugin to load>
    <load plugin>
    .Value = .Value + 1
    DoEvents
<next plugin>

<initialize variables and objects group 1>
.Value = .Value + 1
DoEvents

<initialize variables and objects group 2>
.Value = .Value + 1
DoEvents
 
'    Repeat for each group of variables
'    and objects you initialize
 
<initialize variables and objects group n>
.Value = .Value + 1
DoEvents
 
<initialize interface>
.Value = .Value + 1
DoEvents

End With
Unload frmProgress

This is just a simplified example. The code above would be in the project's loading procedure. frmProgress is the Form with the Progress Bar (ProgressBar1) on it. The With statement just makes it easier to write the rest of the code for the Progress Bar - you can just as easily use frmProgress.ProgressBar1.Value = frmProgress.ProgressBar1.Value + 1 instead.

Hope this clears up more for ya!

- Sendoshin

ok, thank you so much!! have a blessed day! one more pls.. how could i disable the windows keyboard especially the one with the windows,or simply the menu (which opens the start menu and taskbar) i tried using key_press event and have some ascii value for killing the specified key but it doesn't work.. what i want is that it will no longer work if someone pressed this key while vb project is running, so that no one could enter any application.. i think this could be done with API programming or hooking, but i dont have any idea regarding this. pls give me the simplest one.. even the start menu alone. i dont want it to display the start menu. thanks! and may God bless you always!

As I suspected, I tried to answer this question before in another thread. What I didn't realize is that you're the one who asked the question!

However, I'd like to answer the question there, in the interest of keeping the solution in the same place the problem was presented. So, without further adieu, I present this link to the other thread. I hope I can help you more on the other side!

- Sendoshin

i have used combobox for item name help, i need code and itemname in variable when i select item form bombo and i want to move cursor according to adding word in search tex.
pls help me send me coding at susamudre@yahoo.com
regards
santosh

Increment the progress bar in the code that actually loads the program, then call DoEvents to refresh the progress bar's display. For the example I gave above:

Load frmProgress
With frmProgress.ProgressBar1
.Max = <number of progress bar parts>
.Value = 0
 
<read in registry values>
 .Value = .Value + 1
DoEvents
 
<for each plugin to load>
    <load plugin>
    .Value = .Value + 1
    DoEvents
<next plugin>
 
<initialize variables and objects group 1>
.Value = .Value + 1
DoEvents
 
<initialize variables and objects group 2>
.Value = .Value + 1
DoEvents
 
'    Repeat for each group of variables
'    and objects you initialize
 
<initialize variables and objects group n>
.Value = .Value + 1
DoEvents
 
<initialize interface>
.Value = .Value + 1
DoEvents
 
End With
Unload frmProgress

This is just a simplified example. The code above would be in the project's loading procedure. frmProgress is the Form with the Progress Bar (ProgressBar1) on it. The With statement just makes it easier to write the rest of the code for the Progress Bar - you can just as easily use frmProgress.ProgressBar1.Value = frmProgress.ProgressBar1.Value + 1 instead.

Hope this clears up more for ya!

- Sendoshin

Hi Santosh,

Its always better u start a new thread for a new question, or else ur question may go un-noticed.

Anyway here is the code. If u r storing the name in combo list and corresponding ID in Item Data, use this code:

Dim strName As String
Dim strID As Long

strName = Combo1.Text
strID = Combo1.ItemData(Combo1.ListIndex)


Regards
Veena

This article has been dead for over six months. Start a new discussion instead.