473,503 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Public procedures in a Form are not visable to other Modules ?

In my program VPCalc, Public procedures in a Form are not visible to
other Modules.
Is this how it should be?

-Harry http://home.netcom.com/~hjsmith
Jul 17 '05 #1
7 1865
On Wed, 07 Jan 2004 22:44:16 GMT, "Harry J. Smith"
<hj*****@ix.netcom.com> wrote:
In my program VPCalc, Public procedures in a Form are not visible to
other Modules.
Is this how it should be?


Form1.MyProc
Jul 17 '05 #2
J French wrote:
On Wed, 07 Jan 2004 22:44:16 GMT, "Harry J. Smith"
<hj*****@ix.netcom.com> wrote:

In my program VPCalc, Public procedures in a Form are not visible to
other Modules.
Is this how it should be?

Form1.MyProc

Well, yes and no.

They should be public and they probably are: they are public methods of
any instance of the form. So if you have defined a variable as the the
type of your form (supposing is is called "Form1" here):

dim frm as Form1 ' every form definition has its own type
set frm=new Form1 ' create a new instance. You could also get it out
' of the Forms collection
frm.VPcalc ' When you type the dot, VPcalc should be in the
' autocomplete list, as it is public.

Best regards,
Dikkie Dik
Jul 17 '05 #3

"Dikkie Dik" <Ab***@SpamBusters.com> wrote in message
news:3f***********************@dreader-2.news.scarlet-internet.nl...
J French wrote:
On Wed, 07 Jan 2004 22:44:16 GMT, "Harry J. Smith"
<hj*****@ix.netcom.com> wrote:

In my program VPCalc, Public procedures in a Form are not visible to
other Modules.
Is this how it should be?

Form1.MyProc

Well, yes and no.

They should be public and they probably are: they are public methods

of any instance of the form. So if you have defined a variable as the the
type of your form (supposing is is called "Form1" here):

dim frm as Form1 ' every form definition has its own type
set frm=new Form1 ' create a new instance. You could also get it out
' of the Forms collection
frm.VPcalc ' When you type the dot, VPcalc should be in the
' autocomplete list, as it is public.

Best regards,
Dikkie Dik


Thanks, this works great.

First I found that after the new instance of the form, you can ignore
the frm variable:

dim frm as Form1
set frm=new Form1 'Bring up Form1
Set frm = Nothing 'No longer need frm
Form1.VPCalc 'Call the Sub VPCalc

Then I removed the first three lines and the form came up anyway:

Form1.VPCalc 'Call the Sub VPCalc

I tried doing the first two lines by themselves and the form did not
come up. They appear to do nothing but set frm which is not needed.

I will just do the one-liner and be happy I have a solution.

-Harry
Jul 17 '05 #4

"Harry J. Smith" <hj*****@ix.netcom.com> wrote in message
news:Wl**************@newsread1.news.pas.earthlink .net...

First I found that after the new instance of the form, you can ignore
the frm variable:

dim frm as Form1
set frm=new Form1 'Bring up Form1
Set frm = Nothing 'No longer need frm
Form1.VPCalc 'Call the Sub VPCalc

Then I removed the first three lines and the form came up anyway:

Form1.VPCalc 'Call the Sub VPCalc

I tried doing the first two lines by themselves and the form did not
come up. They appear to do nothing but set frm which is not needed.

I will just do the one-liner and be happy I have a solution.

-Harry


When you use Form1.VPCalc, you are using the "implied" instance variable
in VB. This works fine in applications where forms are not frequently
loaded and unloaded.

The other approach is to declare and manage your own instance variables,
as was illustrated. The complete sequence would be:
Dim frm as Form1
Set frm = New Form1
frm.VPCalc
frm.Show

This is mainly an advantage when you need to keep track of more than
one form instance, or want to run VPCalc before showing the form, or
need to manage forms in other ways.

Jul 17 '05 #5

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Z6********************@comcast.com...

"Harry J. Smith" <hj*****@ix.netcom.com> wrote in message
news:Wl**************@newsread1.news.pas.earthlink .net...

First I found that after the new instance of the form, you can ignore the frm variable:

dim frm as Form1
set frm=new Form1 'Bring up Form1
Set frm = Nothing 'No longer need frm
Form1.VPCalc 'Call the Sub VPCalc

Then I removed the first three lines and the form came up anyway:

Form1.VPCalc 'Call the Sub VPCalc

I tried doing the first two lines by themselves and the form did not
come up. They appear to do nothing but set frm which is not needed.

I will just do the one-liner and be happy I have a solution.

-Harry
When you use Form1.VPCalc, you are using the "implied" instance

variable in VB. This works fine in applications where forms are not frequently
loaded and unloaded.

The other approach is to declare and manage your own instance variables, as was illustrated. The complete sequence would be:
Dim frm as Form1
Set frm = New Form1
frm.VPCalc
frm.Show

This is mainly an advantage when you need to keep track of more than
one form instance, or want to run VPCalc before showing the form, or
need to manage forms in other ways.


Right, I have seven forms in my application. Only one needs to have more
than one copy up at the same time. I now use the simple method for all
of the forms but this special one. If I use the simple method for this
one, when you bring up a second copy the first copy goes away.

-Harry
Jul 17 '05 #6

"Harry J. Smith" <hj*****@ix.netcom.com> wrote in message
news:I9***************@newsread1.news.pas.earthlin k.net...


Right, I have seven forms in my application. Only one needs to have more than one copy up at the same time. I now use the simple method for all
of the forms but this special one.
That seems very sensible.
If I use the simple method for this
one, when you bring up a second copy the first copy goes away.


That seems odd. Maybe they are just on top of each other? You should in
principle be able to use Form1 (the implied instance) and frm (the
declared instance) and have two, although most programmers would at this
point just declare two (say frmA and frmB) and not use Form1 at all.
Jul 17 '05 #7

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Rv********************@comcast.com...

"Harry J. Smith" <hj*****@ix.netcom.com> wrote in message
news:I9***************@newsread1.news.pas.earthlin k.net...


Right, I have seven forms in my application. Only one needs to have more
than one copy up at the same time. I now use the simple method for all of the forms but this special one.


That seems very sensible.
If I use the simple method for this
one, when you bring up a second copy the first copy goes away.


That seems odd. Maybe they are just on top of each other? You should

in principle be able to use Form1 (the implied instance) and frm (the
declared instance) and have two, although most programmers would at this point just declare two (say frmA and frmB) and not use Form1 at all.


You’re probably not THAT interested, but I put the compiled version of
the program and all of the source code on my web site. They can be
downloaded from:

http://www.geocities.com/hjsmith_geo...ad.html#VPCalc

-Harry
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2459
by: Ryan.Chowdhury | last post by:
This is a general question regarding the use of view and stored procedures. I'm fairly new to databases and SQL. I've created a SQL database using an Access Data Project ("ADP") and I'm...
2
5455
by: MLH | last post by:
I have a form module that starts out something like this... Option Compare Database 'Use database order for string comparisons ..... Then there's a line like this in it... Public Const...
8
2179
by: WindAndWaves | last post by:
Hi everyone Why do you use the word public in a function, when the function is fully accessible without the word public in front of it. I read the help, but did not really get it. Cheers ...
2
1440
by: MLH | last post by:
A97 allows separate procedures in a form module to share common label names. Access 2.0 would puke when that happened. For instance, if I had 2 procedures in an Access 2.0 form module with labels...
21
4372
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
4
45077
by: Chris | last post by:
Hello, I'm just getting started with VB and am new to the group, so please excuse what may seem to be a rudimentary question. I've been writing basic programs and have noticed that the...
1
1127
by: Paul | last post by:
I have a class library that has a form and MDI class. My applications use this. Each application has a MDI form inherited from the MDI class. Each form that is displayed from within the MDI form...
9
2330
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
2
1661
by: MLH | last post by:
I'm wondering about Public VS Global kewords that can be used in procedures inside global modules saved/viewd in the modules tab of the database window. Is it pretty much the same thing to use one...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.