Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User defined data types 1

Status
Not open for further replies.

fheyn

Programmer
Mar 22, 2001
198
DE
Hi,
I'm using a public class function to retrieve an applications configuration data. To do this, I pass a struct to the function.
On compiling there's an error message which says that
'userdefined datatypes to be used as function-parameters
must be defined in a public object module'.
A public object module I understand is a .bas - module
(please correct me if I'm wrong), and that's where I defined
the Type as well as declared the variable.
Has anyone got an idea how to do this ?
Any help appreciated
thank in advance
 
Not sure, but try putting it in a class module instead.


Have a great day!

j2consulting@yahoo.com
 
Hello PaulBent,

I'm very fuzzy on UDTs, etc. since I have never had the opportunity to use them very much. If you wouldn't mind posting a little bit of working code as an example, I would really appreciate it!


Have a great day!

j2consulting@yahoo.com
 

fheyn, please read FAQ222-2244 Item 15. We can see that you have not responded to a lot of the threads that you have started (2 of 29 with only 12 replies in the 29 that you have started, but I can also see that you have many replies in other threads and I bet you wonder sometimes if your advice helped or not.

so with that said ...


In a bas module you can ...
[tt]
Option Explicit

Public Type MySquare
MyLeft As Integer
MyTop As Integer
MyHeight As Integer
MyWidth As Integer
End Type

Public Sub DrawMySquare(MyS As MySquare)

MsgBox MyS.MyLeft & " " & MyS.MyTop & " " & MyS.MyHeight & " " & MyS.MyWidth

End Sub
[/tt]

and then in form1 or from where ever ...
[tt]
Option Explicit

Dim MySq As MySquare

Private Sub Form_Load()

MySq.MyLeft = 30
MySq.MyTop = 30
MySq.MyHeight = 120
MySq.MyWidth = 120

Call DrawMySquare(MySq)

End Sub
[/tt]

So the error message is saying to you that you have declared you UDT as either private or in a form and you are not referincing with the formname.udt.name.

SBendBuckeye,

UDT's are great ways to keep similar information together so that you can use intellisense to pop up what element you are after.

Good Luck

 
vb5,

It seems like every time I see your name I end up giving you another star. Thanks again for sharing your obvious expertise so freely on the board! As an aside, I've done quite a bit more VBA than VB. When first learning VBA, I used the 2 volume set Access Developers Handbook by Getz, Litwin, etc. very extensively. If you are familiar with that series, is there a VB equivalent you would recommend?


Have a great day!

j2consulting@yahoo.com
 

fheyn,

Was any of this any help???

SBendBuckeye[/t],

Best bet is to goto the book store and open what you can find and take a look inside. Then pick which one(s) you want before its too late.

Good Luck

 
sorry guys
this has been an urgent project. So I went to a different
solution : I retrieve the classdata using public classmethods.
Nonetheless here is a bit of the code :
first, I don't use a form. the app starts with sub main,
using classes and modules.
in the bas-module: Public Type DWTType
fieldName(MAX) As String
fieldType(MAX) As Variant
fieldIndex(MAX) As Long
fieldValue(MAX) As Variant
End Type

and public DWT as DWTType

class myClass : gets the configuration-data of another app
via DLL.
GetData(pDTW as DWTType) <--- here's the error

from sub main I want to do set extData = myClass
extData.GetData(DTW)

that's it and thanks a lot for your response
franz

 
Try using Friend in stead of Public on the extData Class Procedure

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top