Hello,
I created a public Structure in a Standard Module and also
an array of Structures. Then I load data into the array
of structures in a public sub that I call on the Form load
event. Next I have a class, and I want to pass a
structure member from my array of Structures to the class
constructor. In the form I instantiate a class object.
Module1
--------------------------
Public arrStruct() As structOne
Public Structure structOne
....
End Structure
public sub LoadStruct()
....
End Sub
-----------------------------
Form1
form_load event
LoadStruct
....
Dim clsOne(arrStruc t(1)) As New Class1
In the class constructor I have this:
Public Class Class1
Public Sub New(ByVal strcOne As structOne)
var1 = strcOne.element 1
var2 = strcOne.element 2
...
End Sub
....
The compile error I get is
'strcOne' cannot expose a Friend type outside of the
Public class 'Class1'. strcOne is the the argument in the
constructor for Class1. When I instantiate Class1 as
clsOne I pass a member of my array of Structures,
arrStruct(1) where the member is a structure.
Is there anything I can do to get around this error?
Thanks,
Steve 3 1756
OK. One workaround that I just tried which seems to work
is to declare the Class as Friend instead of Public. Any
suggestions appreciated if this is correct or I am just
getting lucky. If it is just luck, I respectfully request
how to do it correctly. -----Original Message----- Hello,
I created a public Structure in a Standard Module and
alsoan array of Structures. Then I load data into the array of structures in a public sub that I call on the Form
loadevent. Next I have a class, and I want to pass a structure member from my array of Structures to the class constructor. In the form I instantiate a class object.
Module1 -------------------------- Public arrStruct() As structOne
Public Structure structOne .... End Structure
public sub LoadStruct() .... End Sub -----------------------------
Form1 form_load event LoadStruct .... Dim clsOne(arrStruc t(1)) As New Class1
In the class constructor I have this:
Public Class Class1 Public Sub New(ByVal strcOne As structOne) var1 = strcOne.element 1 var2 = strcOne.element 2 ... End Sub ....
The compile error I get is
'strcOne' cannot expose a Friend type outside of the Public class 'Class1'. strcOne is the the argument in
theconstructor for Class1. When I instantiate Class1 as clsOne I pass a member of my array of Structures, arrStruct(1) where the member is a structure.
Is there anything I can do to get around this error?
Thanks, Steve .
I believe you should declare you structures as public in the class module;
Class Module
Public Class MyClass
Public Structure MyStruct
......
End Structure
Public Sub New(ByVal FileName As String)
MyBase.New( data as MyStruct)
sClear()
FileH.Name = FileName
End Sub
End Class
............... ............... ........
Module 1
Public Sub Main()
dim aStruct as myClass.MyStruc t
' Set aStruct members to your data
dim newobject as myClass = New MyClass(aStruct )
end sub
"Steve" wrote: OK. One workaround that I just tried which seems to work is to declare the Class as Friend instead of Public. Any suggestions appreciated if this is correct or I am just getting lucky. If it is just luck, I respectfully request how to do it correctly.
-----Original Message----- Hello,
I created a public Structure in a Standard Module and alsoan array of Structures. Then I load data into the array of structures in a public sub that I call on the Form loadevent. Next I have a class, and I want to pass a structure member from my array of Structures to the class constructor. In the form I instantiate a class object.
Module1 -------------------------- Public arrStruct() As structOne
Public Structure structOne .... End Structure
public sub LoadStruct() .... End Sub -----------------------------
Form1 form_load event LoadStruct .... Dim clsOne(arrStruc t(1)) As New Class1
In the class constructor I have this:
Public Class Class1 Public Sub New(ByVal strcOne As structOne) var1 = strcOne.element 1 var2 = strcOne.element 2 ... End Sub ....
The compile error I get is
'strcOne' cannot expose a Friend type outside of the Public class 'Class1'. strcOne is the the argument in theconstructor for Class1. When I instantiate Class1 as clsOne I pass a member of my array of Structures, arrStruct(1) where the member is a structure.
Is there anything I can do to get around this error?
Thanks, Steve .
Steve,
Modules by default are Friends, when you define a Structure inside of a
Module it will also be Friend (despite saying Public on the Structure VB.NET
will not promote the visibility higher then the containing type.
I would move the definition of the Structure outside of the Module.
Module Module1 -------------------------- Public arrStruct() As structOne
public sub LoadStruct() ... End Sub -----------------------------
End Module
Public Structure structOne ... End Structure
I normally define structures in their own source file, where each Structure
is in its own source file.
Hope this helps
Jay
"Steve" <an*******@disc ussions.microso ft.com> wrote in message
news:28******** *************** *****@phx.gbl.. . Hello,
I created a public Structure in a Standard Module and also an array of Structures. Then I load data into the array of structures in a public sub that I call on the Form load event. Next I have a class, and I want to pass a structure member from my array of Structures to the class constructor. In the form I instantiate a class object.
Module1 -------------------------- Public arrStruct() As structOne
Public Structure structOne ... End Structure
public sub LoadStruct() ... End Sub -----------------------------
Form1 form_load event LoadStruct ... Dim clsOne(arrStruc t(1)) As New Class1
In the class constructor I have this:
Public Class Class1 Public Sub New(ByVal strcOne As structOne) var1 = strcOne.element 1 var2 = strcOne.element 2 ... End Sub ...
The compile error I get is
'strcOne' cannot expose a Friend type outside of the Public class 'Class1'. strcOne is the the argument in the constructor for Class1. When I instantiate Class1 as clsOne I pass a member of my array of Structures, arrStruct(1) where the member is a structure.
Is there anything I can do to get around this error?
Thanks, Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: muser |
last post by:
The following function gives me the following error: warning C4700:
local variable 'Newirrecord' used without having been initialized.
Newirrecord is the instance of a structure. I get the same in another
function as well, where an ordinary variable gives me the same
warning.
isn't strncpy passing a string to partnum which in turn I access with
Newirrecord.partnum? Shouldn't Newirrecord.partnum contain something
at run time?
|
by: Sandy |
last post by:
Hi,
I have some data stored in my internal data structure. I am writing this
data in an xml file and invoking xalan on this file to perform some
transformation.
After the transformation I want to put the data in Database so i m reading
the xml produced by xalan.
But as there are lot of IO operations so the application is very slow.
Is there any way to pass the xml stream (using the string buffer that I am
|
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and click a button to
determine whether the zip code is unique. If the zip code is not unique,
another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip
code and zipid are both passed to the lookup form/dialog by reference. I...
|
by: Robert W. |
last post by:
I have a data model with this structure:
Class
PropertyA
PropertyB
Collection
Class
Property1
Property2
The outermost class has a handler that correctly deals with events fired by
|
by: Ashwin |
last post by:
hi guys,
i have overloaded the << operator.as shown below.
ostream& operator<<(ostream &out, const student &a)
{
out<<a.idno;
out<< " " ;
// out<< a.name;
out<< " " ;
// out<< a.marks << endl;
| |
by: aaragon |
last post by:
Hi everyone. I'm trying to write a class with policy based design
(Alexandrescu's Modern C++ Design). I'm not a programmer but an
engineer so this is kind of hard for me. Through the use of policies,
I want to customize the structure of a class. The idea is to
investigate the use of several data structures. One option would be
the use of the boost dynamic bitset. Another would be the use of the
std::vector. I obtained some code that...
|
by: nass |
last post by:
this is a thought experiment.
i do not have the time to implement it and test it to see if it works
so i am relying on your good will:)
thank you in advance
im on a linux machine (slackware 10.2) on an i686 intell processor.
its my first attempt to convert a fileIO procedure, to a pthread so it
won't stall the execution of the code.
im going through an online tutorial
|
by: ishwarbg |
last post by:
Hi Everyone,
I have a .Net Application, through which I am invoking a function from a legacy DLL developed in C++. My structure in C# contains some data of type double which I need to pass to to the DLL to get some results back from it.
My Structure In C# looks like this:
public struct InputPurchaseOrder
{
public System.String poJobName;
|
by: efrenba |
last post by:
Hi,
I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.
I need to insert new features to an old program that I wrote in delphi
and it's a good opportunity to start with c++.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |