473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Exposing sub outside form

Hi

How can I expose a sub outside a form so it is available globally?

Thanks

Regards
Feb 3 '08 #1
5 844
just declare it

Public Sub Foo()

End Sub

and anything can see it. Hope this helps

--Jon
Feb 3 '08 #2
John,

Make it from private public, be aware however that you are violating direct
all rules of OOP than,.

Cor

"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:ey*************@TK2MSFTNGP04.phx.gbl...
Hi

How can I expose a sub outside a form so it is available globally?

Thanks

Regards
Feb 3 '08 #3
GS
try this

Friend sub mysub
end sub
the keywords "Protected Friend" allows any code within the application
namespace to access the sub

But if you want any code including those outside your project you may want
to try
Public instead of "Protected Friend"

"John" <Jo**@nospam.infovis.co.ukwrote in message
news:ey*************@TK2MSFTNGP04.phx.gbl...
Hi

How can I expose a sub outside a form so it is available globally?

Thanks

Regards


Feb 3 '08 #4
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:AC**********************************@microsof t.com...
John,

Make it from private public, be aware however that you are violating
direct all rules of OOP than,.

Cor
Cor,

Simply making a private sub public doesn't violate OOP. You are allowed
to extend and republish a published interface and it won't break existing
code. Going the other way could break existing code. In addition, a sub
doesn't return anything, so unless there are byref arguments, no information
about the internal structure and state of the form object can be returned,
making it impossible for violation of encapsulation.

Mike
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:ey*************@TK2MSFTNGP04.phx.gbl...
>Hi

How can I expose a sub outside a form so it is available globally?

Thanks

Regards



Feb 3 '08 #5
Michael,

(and now the true one).

You are right, however I don't like all those public member to do this kind
of things (and I am violating to it as needed).

Cor
Feb 4 '08 #6

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

Similar topics

1
by: Markus | last post by:
Hi, I am trying to query the value of a textfield outside of a form but with no success so far... the reason why I am not using a form is that there seams to be an annoying issue with hitting...
3
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. ...
3
by: Prigozhin Roman | last post by:
But if I do this, then later in the code where I'm implementing set and get functions I'm getting error : Class already contains a definition for 'MyProperty'. Probably I'm not implementing...
3
by: Jason | last post by:
I'm trying to implement some pretty basic behavior in c#/.net 1.1 Forms but can't seem to find all the requisite pieces. When a user clicks on the background of the form, I want the app to start...
3
by: FredC | last post by:
How do you make a program's properties and methods availale so that other programs can "connect" to them at design time and then use them at run time?
3
by: bill | last post by:
I need to open a asp.net web form from a classic asp page, and pass a username and password to the asp.net page. The username and password exist as session variables in the classic asp...
2
by: Yuk Tang | last post by:
I've satisfactorily got an axwebbrowser control on a form within a panel, suitably positioned and sized, and now I want to display a webpage on it. This is not normally a problem when I have the...
2
by: Rich | last post by:
Greetings, I observed that in VB2005 the designer generated code is hidden. The initialize code appears to be stored in a different module than the Form's class module. But the form's class...
4
by: Jim Carlock | last post by:
I've been using global to expose variables. However, I noticed the following... (1) global seems to use the nearest declaration. For example, // module1.php $sMyString = "Hello World.";
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.