Performance Issue and Solutions
Hi All,
I'm working on a VB Application that contains MDI frmMain, frmIndex, and more child forms. Everytime
I cancelled out of one of the child forms and try to open another child form, it takes at least 15 seconds or more to open it. I want to know what is best solution to keep the user aware that the system is working? I'm thinking of 3 possible options:
1. Put in a hourglass
2. A progress bar in the status bar
3. Status bar with descriptive text indicating the program is loading
Does anyonw have any idea which option is the best and why you choose that option? Or are there any other options? Does anyone have any VB codes that they want to share with me that does the job of any of these above options?
Your help is appreciated!
Thanks
Anne
Beginner in VB
[843 byte] By [
Anne Smith] at [2007-11-15 15:30:35]

# 2 Re: Performance Issue and Solutions
The following is my personal preference
1. Progress bar (if you know the progress of your operation and the process takes so long as fifteen seconds)
2. Status bar message with a hourglass
I don't like the blocky look of the Windows progress bar. And besides, it doesn't allow descriptive text within it.
Here is the form code for implementing a better progress bar.
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5355
ClientLeft = 60
ClientTop = 345
ClientWidth = 6735
LinkTopic = "Form1"
ScaleHeight = 5355
ScaleWidth = 6735
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1200
TabIndex = 4
Top = 1080
Width = 1455
End
Begin VB.PictureBox picProgress
Align = 2 'Align Bottom
FillColor = &H00E0E0E0&
FillStyle = 0 'Solid
Height = 300
Left = 0
ScaleHeight = 36.363
ScaleMode = 0 'User
ScaleWidth = 445
TabIndex = 0
Top = 5055
Width = 6735
Begin VB.PictureBox picFiller
AutoRedraw = -1 'true
BackColor = &H80000006&
BorderStyle = 0 'None
Height = 300
Left = 0
ScaleHeight = 20
ScaleMode = 3 'Pixel
ScaleWidth = 1
TabIndex = 1
Top = 0
Width = 15
Begin VB.Label lblWhite
AutoSize = -1 'true
BackStyle = 0 'Transparent
Caption = "Processing..."
ForeColor = &H8000000E&
Height = 195
Left = 0
TabIndex = 2
Top = 0
Width = 915
End
End
Begin VB.Label lblBlack
AutoSize = -1 'true
Caption = "Processing..."
ForeColor = &H00000000&
Height = 195
Left = 0
TabIndex = 3
Top = 0
Width = 915
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = false
Attribute VB_Creatable = false
Attribute VB_PredeclaredId = true
Attribute VB_Exposed = false
public Sub Progress(Ratio as Single)
'This advances the "progress bar" according to Ratio
picFiller.Width = picProgress.ScaleWidth * Ratio
DoEvents
End Sub
public Sub ProgInit(Message as string)
'This makes preparations for the "Progress Bar"
lblBlack.Caption = Message
lblWhite.Caption = Message
picFiller.Visible = true
picFiller.Width = 1
DoEvents
End Sub
public Sub ProgEnd()
'This makes cleanup for the "Progress Bar"
picFiller.Visible = false
lblBlack.Caption = "Ready"
DoEvents
End Sub
private Sub Command1_Click()
ProgInit ("time consuming task under way....")
for i = 1 to 1000000
Progress i / 1000000
next
ProgEnd
End Sub
Copying and pasting color coded code in dev-archive to VB will cause all lines to appear on one single line. It is quite tedious to repair the code. There is a workaround though. Copy the code and paste to MS Word or to WordPad, the lines will remain separate. Then copy it from here and paste it in VB.
shree at 2007-11-10 1:09:58 >

# 4 Re: Performance Issue and Solutions
Hi,
just out of interest, how many child windows are open when this operation takes 15 seconds and how many controls do you have on them? 15 seconds is an awful long time just to load a window, unless there is another reason (e.g. it needs to load some info from an external file maybe?)
Using a progress bar seems quite strange to me, if you dont know what is causing the delay and therefore cannot predict how it will behave on each individual system (or maybe you do...). Of course this is only my opinion, but I believe an animated hourglass may be the most suitable. If you have a status bar on the parent form, you could change the text as well.
This seems more sensible to me since you are informing the user that the operation will take some time without giving a false indication.
If you need help with using an animated cursor, I suggest http://www.planet-source-code.com/xq/ASP/txtCodeId.4677/lngWId.1/qx/vb/scripts/ShowCode.htm There are also many other examples on the PSC website.
psiclone.