User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 29 Oct 2004, 16:28   #1
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
VB - eew - User defined types as parameters for class member functions

Against my will I am forced to work with VB6 and I want to do some fancy stuff with it that looks a bit like OOP. I know the OO support in VB6 isn't really great (understatement?) but I'm stuck with it, and I still want to use it for some generic "modules".
I'm stuck on using a user defined type as a parameter in a function of a class-module (as it's called in VB6).

Code:
'//Class module class1

public function func(aa As MyType) As Integer '//Error here
  'Stuff
end function

public function func2(ByRef aa As MyType) As Integer '//Error here
  'Stuff
end function
Code:
'//module modMyModule

Public Type MyType
  memberVar As String
End Type
In the class-module I get the following error:
"Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types"

That's a mouthfull, but I'm not sure what on earth I'm doing wrong. What's this "Object module" they are talking about in the error? There is no module called "Object module" in the IDE. Just "Module".
How can I use my own types in class functions? Or am I pushing VB6 too far for my needs now?
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 29 Oct 2004, 21:02   #2
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
Arrow Re: VB - eew - User defined types as parameters for class member functions

Hm I just tried it, and it indeed seems ****ing annoying. I can't see why this happens and the error message in german is not much more helpful as well. Also the help-button leads me nowhere.
Hm.
Pretty shitty.

Tried to do more than one type-declaration etc, doesn't work. Sad.
But there must be a way around this.


Maybe the concept of userdefined datatypes <-> subclassing doesn't quite work well together?


In the end, WHY do you have MyType? You should be using a class there!

If nothing helps, you may need a wrapper-funktion in a module, that accepts a userdefined datatype and returns and object / class with set properties. No?


And you do have SP6, right?
__________________
[»] Entropy increases! :-/
JetLinus is offline   Reply With Quote
Unread 29 Oct 2004, 23:15   #3
Caesar2
Commander
 
Caesar2's Avatar
 
Join Date: Sep 2001
Location: Netherlands
Posts: 146
Caesar2 is just really niceCaesar2 is just really niceCaesar2 is just really niceCaesar2 is just really nice
Re: VB - eew - User defined types as parameters for class member functions

Use
Code:
Friend Function
instead of
Code:
Public Function
__________________
Quote:
Originally posted by Cochese
Cathaar are not overpowered.

You were just "bashed", live with it.
Caesar2 is offline   Reply With Quote
Unread 30 Oct 2004, 08:37   #4
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Re: VB - eew - User defined types as parameters for class member functions

Quote:
Originally Posted by JetLinus
In the end, WHY do you have MyType? You should be using a class there!
I'm trying to make a database module and one of the features is to be able to create aliases on a table/column. For this I have an alias type with a string aliasName, tableName and fieldName. Using a class seemed a bit overkill to me at the moment

Quote:
Originally Posted by JetLinus
If nothing helps, you may need a wrapper-funktion in a module, that accepts a userdefined datatype and returns and object / class with set properties. No?

And you do have SP6, right?
I might try that, and yes, I have SP6 installed.

Quote:
Originally Posted by Caesar2
Use
Code:
Friend Function
instead of
Code:
Public Function
Will try this monday when I get back at work.
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 1 Nov 2004, 17:12   #5
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Re: VB - eew - User defined types as parameters for class member functions

\o/ happy happy... it works! \o/
TY!
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 23:45.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018