By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

passing a structure

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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.com> wrote in message
news:41***************@mail.com...
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

P: n/a
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.com> wrote in message
news:41***************@mail.com...
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

P: n/a
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.com> wrote in message
news:41***************@mail.com...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

P: n/a
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.com> wrote in message
news:41***************@mail.com...
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 discussion thread is closed

Replies have been disabled for this discussion.