|
-
Sep 15th, 2016, 09:23 PM
#34
Re: Problem with Public UDT: 'Only public user defined types......
neotechni,
It's really easy to convert a UDT into a Class. Let's say you have the following UDT:
Code:
Public Type MyUdtType
i1 As Long
i2 As Long
s1 As String
s2 As String
End Type
And then, somewhere in your code, you do this...
Code:
Dim MyUdt As MyUdtType
All you need to do is start a new class. We'll call it MyClass. And then take the elements of your UDT (cutting of the Public Type... and the End Type), and paste the into the top of your class, and declare them as Public, like so:
Code:
Public i1 As Long
Public i2 As Long
Public s1 As Long
Public s2 As Long
And then, where you originally declared a variable with your UDT, just do the following instead...
Code:
Dim MyUdt As New MyClass
Voila, MyUdt is now actually a class and not a true UDT, but it'll work exactly the same, with the added advantage that it'll pass into and out of other objects.
Regards,
Elroy
EDIT1: Another option is to leave it as a UDT, and then just make sure all procedures (in objects [forms and classes]) are declared as "Friend".
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|