473,651 Members | 3,093 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 1870
On Wed, 07 Jan 2004 22:44:16 GMT, "Harry J. Smith"
<hj*****@ix.net com.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.net com.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***@SpamBust ers.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.net com.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.net com.com> wrote in message
news:Wl******** ******@newsread 1.news.pas.eart hlink.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******** ************@co mcast.com...

"Harry J. Smith" <hj*****@ix.net com.com> wrote in message
news:Wl******** ******@newsread 1.news.pas.eart hlink.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.net com.com> wrote in message
news:I9******** *******@newsrea d1.news.pas.ear thlink.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******** ************@co mcast.com...

"Harry J. Smith" <hj*****@ix.net com.com> wrote in message
news:I9******** *******@newsrea d1.news.pas.ear thlink.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
2470
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 satified with the table structure. I've moved on to building some front ends for our users. I'm running into situations where I want subreports to be built from queries that are dependent on the values in other controls. I've played with stored...
2
5464
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 MyVar = 0 Clicking Run, Compile gives rise to an error there. Am I not supposed
8
2186
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 Nicolaas
2
1442
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 both named ERR_MyButton_Click, compiling loaded modules produced an error. I'm glad to see this is not the case in Access 97. Access 2.0 went so far as to disallow me from using the same line numbers in two different procedures of a form module....
21
4400
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 if "global variables get re-set" doesn't tell the whole story, then what does? ***please note*** I'm not looking for a solution - I'm looking for a more detailed description of what happens when an un-handled error occurs - possibly with help file...
4
45129
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 syntax for some of these functions have been set up with the keywords "Public Shared Function" (for example, the Trim function) and others are set up just as "Public
1
1135
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 is inherited from the class library form. In addition to all that I have modules in the applications. I need an object that is available to all to store user information. So when the MDI form is loaded, I want the form to get the user...
9
2348
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 = CDec(txbInv.Text) Wage = CDec(txbTotWage.Text)
2
1667
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 or the other when declaring a global variable? If not, what is (are) the major difference(s) ?
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8467
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
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 we have to send another system

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.