Hi all,
In a module I have the following structure..
Public Structure ButtonStatusFlags
Public butOK As Boolean
Public butNew As Boolean
Public butView As Boolean
End Structure
And in a usercontrol at class-level I want to declare one of these as
protected..
Protected ButtonStatus As ButtonStatusFlags
this gives me the error 'ButtonStatus cannot expose a Friend type outside of
the public class 'ucMyControl'
However I am able to declare it as FRIEND. This does not make sense to me as
ButtonStatus will be exposed MORE. ie to inheriting classes and outside
Can someone explain why this is so??
I can achieve what I want by moving my structure definition into my
usercontrol class, but I would like to keep it public so that I can use it
elsewhere without having to redefine it in each class.
thanks in advance
Steve 5 1170
Just a suggestion...I would think a usercontrol class that would possibly be
used on different forms in different applications should be encapsulated,
i.e., not rely on external classes. I would move the class to inside the
control class since it's such a simple class. Another solution would be to
create a class library containing the buttonclass and add that to your
usercontrol project. You could then also use the class library in other
projects.
"Steve" wrote: Hi all,
In a module I have the following structure..
Public Structure ButtonStatusFlags
Public butOK As Boolean Public butNew As Boolean Public butView As Boolean
End Structure
And in a usercontrol at class-level I want to declare one of these as protected.. Protected ButtonStatus As ButtonStatusFlags
this gives me the error 'ButtonStatus cannot expose a Friend type outside of the public class 'ucMyControl'
However I am able to declare it as FRIEND. This does not make sense to me as ButtonStatus will be exposed MORE. ie to inheriting classes and outside
Can someone explain why this is so??
I can achieve what I want by moving my structure definition into my usercontrol class, but I would like to keep it public so that I can use it elsewhere without having to redefine it in each class.
thanks in advance
Steve
Just a suggestion...I would think a usercontrol class that would possibly be
used on different forms in different applications should be encapsulated,
i.e., not rely on external classes. I would move the class to inside the
control class since it's such a simple class. Another solution would be to
create a class library containing the buttonclass and add that to your
usercontrol project. You could then also use the class library in other
projects.
"Steve" wrote: Hi all,
In a module I have the following structure..
Public Structure ButtonStatusFlags
Public butOK As Boolean Public butNew As Boolean Public butView As Boolean
End Structure
And in a usercontrol at class-level I want to declare one of these as protected.. Protected ButtonStatus As ButtonStatusFlags
this gives me the error 'ButtonStatus cannot expose a Friend type outside of the public class 'ucMyControl'
However I am able to declare it as FRIEND. This does not make sense to me as ButtonStatus will be exposed MORE. ie to inheriting classes and outside
Can someone explain why this is so??
I can achieve what I want by moving my structure definition into my usercontrol class, but I would like to keep it public so that I can use it elsewhere without having to redefine it in each class.
thanks in advance
Steve
Steve, In a module I have the following structure..
Ah! There's the rub.
Structures do not need to be in a Module, rather then can be in there own
source file. Remember that Modules default to Friend not Public, so when you
have "Module SomeModule" it is really saying "Friend Module SomeModule".
Instead of:
---x--- begin SomeModule.vb ---x---
Module SomeModule Public Structure ButtonStatusFlags
Public butOK As Boolean Public butNew As Boolean Public butView As Boolean
End Structure
End Module
---x--- end SomeModule.vb ---x---
I normally put each structure in their own source file:
---x--- begin ButtonStatusFlags.vb ---x--- Public Structure ButtonStatusFlags
Public butOK As Boolean Public butNew As Boolean Public butView As Boolean
End Structure
---x--- end ButtonStatusFlags.vb ---x---
Normally I have a single type (Class, Structure, Enum, Module) in each
source file, I normally put Delegates in the same file as the type they are
closest associated with. Depending on how the Delegate is being used, I will
nest it in another type.
Hope this helps
Jay
"Steve" <@> wrote in message
news:42***********************@news.optusnet.com.a u... Hi all,
In a module I have the following structure..
Public Structure ButtonStatusFlags
Public butOK As Boolean Public butNew As Boolean Public butView As Boolean
End Structure
And in a usercontrol at class-level I want to declare one of these as protected.. Protected ButtonStatus As ButtonStatusFlags
this gives me the error 'ButtonStatus cannot expose a Friend type outside of the public class 'ucMyControl'
However I am able to declare it as FRIEND. This does not make sense to me as ButtonStatus will be exposed MORE. ie to inheriting classes and outside
Can someone explain why this is so??
I can achieve what I want by moving my structure definition into my usercontrol class, but I would like to keep it public so that I can use it elsewhere without having to redefine it in each class.
thanks in advance
Steve
Steve, In a module I have the following structure..
Ah! There's the rub.
Structures do not need to be in a Module, rather then can be in there own
source file. Remember that Modules default to Friend not Public, so when you
have "Module SomeModule" it is really saying "Friend Module SomeModule".
Instead of:
---x--- begin SomeModule.vb ---x---
Module SomeModule Public Structure ButtonStatusFlags
Public butOK As Boolean Public butNew As Boolean Public butView As Boolean
End Structure
End Module
---x--- end SomeModule.vb ---x---
I normally put each structure in their own source file:
---x--- begin ButtonStatusFlags.vb ---x--- Public Structure ButtonStatusFlags
Public butOK As Boolean Public butNew As Boolean Public butView As Boolean
End Structure
---x--- end ButtonStatusFlags.vb ---x---
Normally I have a single type (Class, Structure, Enum, Module) in each
source file, I normally put Delegates in the same file as the type they are
closest associated with. Depending on how the Delegate is being used, I will
nest it in another type.
Hope this helps
Jay
"Steve" <@> wrote in message
news:42***********************@news.optusnet.com.a u... Hi all,
In a module I have the following structure..
Public Structure ButtonStatusFlags
Public butOK As Boolean Public butNew As Boolean Public butView As Boolean
End Structure
And in a usercontrol at class-level I want to declare one of these as protected.. Protected ButtonStatus As ButtonStatusFlags
this gives me the error 'ButtonStatus cannot expose a Friend type outside of the public class 'ucMyControl'
However I am able to declare it as FRIEND. This does not make sense to me as ButtonStatus will be exposed MORE. ie to inheriting classes and outside
Can someone explain why this is so??
I can achieve what I want by moving my structure definition into my usercontrol class, but I would like to keep it public so that I can use it elsewhere without having to redefine it in each class.
thanks in advance
Steve
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl... Steve, In a module I have the following structure.. Ah! There's the rub.
Structures do not need to be in a Module, rather then can be in there own source file. Remember that Modules default to Friend not Public, so when you have "Module SomeModule" it is really saying "Friend Module SomeModule".
thanks for clearing that up. I had assumed that as long as the structure
definition was accessible, I should be be able to instantiate one with
whatever scope I wanted. Now I see this is not the case.
I've just established that it works if I just declare the module containing
the structure as public. I think I'll just do that for this project.
thankyou both for your replies
Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Arthur J. O'Dwyer |
last post by:
I was paging through Coplien's book "Advanced C++ Programming Styles
and Idioms" this afternoon and found some code that looked something
like
void sort(vector<foo> a)
{
int flip;
do {
for...
|
by: kazack |
last post by:
Hi all it's me again with another question as I got further in my book. The
chapter I am in covers structres, abstract data and classes. I only read
through to the end of the coverage on...
|
by: Hamish |
last post by:
I havea program which on execution gives unpredictable behaviour (it
shouldn't). In trying to track down the problem, I'm wondering if there is a
difference between these two ways of filling a...
|
by: Steve Jorgensen |
last post by:
In a recent thread, RKC (correctly, I believe), took issue with my use of
multiple parameters in a Property Let procedure to pass dimensional
arguments on the basis that, although it works, it's...
|
by: thomasfarrow |
last post by:
At work, our development team has a development standards document that
insists Structures should never be used. I'm looking to change this
standard but need a suitable argument in order to make...
|
by: Martin Joergensen |
last post by:
Hi,
I wanted to try something which I think is a very good
exercise... I read in data from the keyboard and store them in a
structure. There's a pointer called "data_pointer" which I use to...
|
by: Roland |
last post by:
The following issue is puzzling me:
There are 2 ways of writing the code below:
....
Dim fnt as Font = New Font(...)
DrawString(myText, fnt,...)
fnt.dispose().
or
DrawString(myText, New...
|
by: gcary |
last post by:
I am having trouble figuring out how to declare a pointer to an array
of structures and initializing the pointer with a value. I've looked
at older posts in this group, and tried a solution that...
|
by: Tom Cole |
last post by:
I'm working on a small Ajax request library to simplify some tasks
that I will be taking on shortly. For the most part everything works
fine, however I seem to have some issues when running two...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |