|
-
Apr 14th, 2005, 04:28 AM
#1
Thread Starter
Member
speed about Public function
I have develped one program with multiple-forms. say, currently I write code in FormA,If i want to use the public function which is defined at formB, I should first reference formB then use syntax like formB.function(...).
i am now wandering the speed of this method. I guess i can define the same function inside the two forms and use them.
will this method be faster than the first one?
I appreciate any inputs
-
Apr 14th, 2005, 07:33 AM
#2
Thread Starter
Member
Re: speed about Public function
then do you know which one runs faster?
-
Apr 14th, 2005, 10:25 AM
#3
Re: speed about Public function
If your form objects are all in existence when you want to call functions on different ones, it should make no difference at all whether you put the function on the form, or in a module. In each case, there is an instance of a class, and the code will have to find the address of the function within the class, and call it. A shared function might be slightly faster, and a local function within a form might be faster than calling a function in a separate form. However, in either case, the speed difference will be insignificant. There are almost certainly better ways to improve speed than the minor advantage you MIGHT get by making local copies of functions.
By the way, if you have to first create form B before you call a function on it, then it is definitely much slower than the other options.
My usual boring signature: Nothing
 
-
Apr 14th, 2005, 08:20 PM
#4
Thread Starter
Member
Re: speed about Public function
Thanks for your reply,Shaggy Hiker.
My program was written by VB6 by use of Recordset to connecting Access Database. Now I tried to migrate VB6 to VB.NET by using ADO.NET dataset object. However, after I completed the program, i found out that the speed of the new one is very much slower than the old one,especially when you pop up a new form.
-
Apr 15th, 2005, 11:19 AM
#5
Re: speed about Public function
Well, there may not be a happy answer to your problem. .NET is slower than VB6, so that is affecting you. If you used DAO in the VB6 version, and have switched to ADO, the speed will be considerably slower, as well.
You really shouldn't have much slowdown switching between forms, but under certain circumstances, I have seen this happen. Laptops have been particularly bad about taking alot of time to load forms the first time they are needed.
I'm afraid that you will need to play around with different solutions. If you are getting significant slowdown with loading forms, then move the sub out of the form into a module, or make a new copy, as you suggested. That new copy idea is generally harder to maintain because whenever you change one, you'll have to remember to change the other, but it is valid to use more tedious code if it produces noticeable improvements in speed.
My usual boring signature: Nothing
 
-
Apr 15th, 2005, 01:23 PM
#6
Frenzied Member
Re: speed about Public function
However, after I completed the program, i found out that the speed of the new one is very much slower than the old one,especially when you pop up a new form.
i have seen this happens because the form's background picture, well while vb6 was very fast in drawing images as background forms, Vb.net is terrible when it comes to background images. the forms pop up toooo slow and the screen flickers while switching between forms and so on.
i would rather use the paint method of the form to draw the backfround myself instead of loading the form with a background image.
i have tried it and i have avoided this speed drawback.
but i am not sure that is your case, may be you don't use background images in the first place
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|