473,698 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing a structure

I want to call a function using my own data type as an argument. The
declaration for my function looks like this:

Public Function CreateCardInfo( ByVal data As WoData)
VB.NET balks at this, saying:

'data' cannot expose a Friend type outside of the Public class
'frmMain'.
The Structure WoData is defined in a module, with Public access:

Public Structure WoData
Dim CUST_NAME As String
Dim MFG_SITE As String
Dim PO_NO, SO_NO, LINE_NO As String
Dim DUE_DATE As String
Dim WO_NO As String
Dim QTY As Integer
End Structure

What to do, please?

Thanks
Nov 21 '05 #1
4 4043
Define your Module as Public. Since you are using the structure as an
argument to a public method, the structure should be available publicly as
well. However, since you've defined your module Friend (not specifying an
access modifier defaults it to Friend), the structure also has 'Friend'
visibility which is why you get the error saying the your structure is a
friend type and cannot be exposed outside a public class.

hope that helps..
Imran.

"Dave Cullen" <no*****@mail.c om> wrote in message
news:41******** *******@mail.co m...
I want to call a function using my own data type as an argument. The
declaration for my function looks like this:

Public Function CreateCardInfo( ByVal data As WoData)
VB.NET balks at this, saying:

'data' cannot expose a Friend type outside of the Public class
'frmMain'.
The Structure WoData is defined in a module, with Public access:

Public Structure WoData
Dim CUST_NAME As String
Dim MFG_SITE As String
Dim PO_NO, SO_NO, LINE_NO As String
Dim DUE_DATE As String
Dim WO_NO As String
Dim QTY As Integer
End Structure

What to do, please?

Thanks

Nov 21 '05 #2
If you used a VB.NET standard module it will have been given Friend scope
implicitly unless you added the keyword Public e.g.

Module X - Friend scope implied.

Public Module X - Public scope explictly declared.
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Dave Cullen" <no*****@mail.c om> wrote in message
news:41******** *******@mail.co m...
I want to call a function using my own data type as an argument. The
declaration for my function looks like this:

Public Function CreateCardInfo( ByVal data As WoData)
VB.NET balks at this, saying:

'data' cannot expose a Friend type outside of the Public class
'frmMain'.
The Structure WoData is defined in a module, with Public access:

Public Structure WoData
Dim CUST_NAME As String
Dim MFG_SITE As String
Dim PO_NO, SO_NO, LINE_NO As String
Dim DUE_DATE As String
Dim WO_NO As String
Dim QTY As Integer
End Structure

What to do, please?

Thanks

Nov 21 '05 #3
Dave,
In addition to the other comments, move the structure outside of the Module.
In other words define the WoData Structure in a file by itself. What I will
do is add a Class or Module to my project then change the Class or Module
keywords to Structure or Interface.

Something like:

---x--- begin WoData.vb ---x---
Option Strict On
Option Explicit On
Public Structure WoData
Dim CUST_NAME As String
Dim MFG_SITE As String
Dim PO_NO, SO_NO, LINE_NO As String
Dim DUE_DATE As String
Dim WO_NO As String
Dim QTY As Integer
End Structure

---x--- end WoData.vb ---x---

Hope this helps
Jay

"Dave Cullen" <no*****@mail.c om> wrote in message
news:41******** *******@mail.co m...I want to call a function using my own data type as an argument. The
declaration for my function looks like this:

Public Function CreateCardInfo( ByVal data As WoData)
VB.NET balks at this, saying:

'data' cannot expose a Friend type outside of the Public class
'frmMain'.
The Structure WoData is defined in a module, with Public access:

Public Structure WoData
Dim CUST_NAME As String
Dim MFG_SITE As String
Dim PO_NO, SO_NO, LINE_NO As String
Dim DUE_DATE As String
Dim WO_NO As String
Dim QTY As Integer
End Structure

What to do, please?

Thanks

Nov 21 '05 #4
That did it, thank you.

drc
Imran Koradia wrote:

Define your Module as Public. Since you are using the structure as an
argument to a public method, the structure should be available publicly as
well. However, since you've defined your module Friend (not specifying an
access modifier defaults it to Friend), the structure also has 'Friend'
visibility which is why you get the error saying the your structure is a
friend type and cannot be exposed outside a public class.

hope that helps..
Imran.

"Dave Cullen" <no*****@mail.c om> wrote in message
news:41******** *******@mail.co m...
I want to call a function using my own data type as an argument. The
declaration for my function looks like this:

Public Function CreateCardInfo( ByVal data As WoData)
VB.NET balks at this, saying:

'data' cannot expose a Friend type outside of the Public class
'frmMain'.
The Structure WoData is defined in a module, with Public access:

Public Structure WoData
Dim CUST_NAME As String
Dim MFG_SITE As String
Dim PO_NO, SO_NO, LINE_NO As String
Dim DUE_DATE As String
Dim WO_NO As String
Dim QTY As Integer
End Structure

What to do, please?

Thanks

Nov 21 '05 #5

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

Similar topics

5
34367
by: kazack | last post by:
I am a little confused with code I am looking at. My c++ book does not go into passing a structure to a function so I pulled out a c book which does. and I do not understand the prototype verses the actual function call. I will post the code below of the structure, the prototype and and function call and if someone can explain this I would be very appreciative: struct data { float amount; string fname;
2
4843
by: Steve Turner | last post by:
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows: typedef struct tag_scanparm { short cmd; short fdc; WORD dsf; short boxcar; short average; short chan_ena;
15
14867
by: John Alway | last post by:
Hello, I'm using a DLL I wrote in C++, and am attempting to call and use it from VB. This works fine for functions where I pass parameters by value, but I can't get pointers to work. I get the following error in the VB.net application: "An unhandled exception of Type
7
2633
by: Jake Thompson | last post by:
Hello I created a DLL that has a function that is called from my main c program. In my exe I first get a a pointer to the address of the function by using GetProcAddress and on the dll side I make sure that my function is being exported by adding a line to the .def file. This seems to work because when I debug it recognizes the dll and once it hits the function it goes right into the proper location of the dll.
11
4128
by: Macca | last post by:
Hi, I'm writing an application that will pass a large amount of data between classes/functions. In C++ it was more efficient to send a pointer to the object, e.g structure rather than passing the actual structure itself. Is this true of C# also?
3
2127
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;
1
1772
by: sharadvasista | last post by:
I have a structure typedef struct t_abcd { int a; int b; int c; } abcd; I have to pass the structure to another function. I can do this in two ways.
7
2153
by: pereges | last post by:
which one do you think is better ? I need to make my program efficient and in some places I have passed the copy of a variable which makes life some what easy while writing huge expressions but they do requrie much more memory than a simple pointer.
6
3881
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper for a C++ DLL file, but am having problems with passing strings as parameters. How should I be writing my C# function call when the C header file is definined as taking a char * as an argument? For example the C++ header says SDCERR GetCurrentConfig(DWORD *num, char *name); I am using Uint for the *num parameter, which returns the correct value but for *name, I always get back a string of 6 squares....
13
3198
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper in C# for an SDK that has been supplied as a .LIB file and a .h header file. I have got most of the functions to work but am really struggling with the functions that require a structure to be passed to them. The function declaration in the .h file is of the form: SDCERR GetConfig(char *name, SDCConfig *cfg); where SDCConfig is a structure defined in the .h file. I am not much of a C (or C#)...
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
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,...
0
9171
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...
1
8905
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
8880
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 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...
0
7743
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
6532
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
4373
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...
3
2008
bsmnconsultancy
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...

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.