用户定义类型 (UDT) 作为类模块 (VB6) 中公共子类中的参数 [英] User Defined Type (UDT) as parameter in public Sub in class module (VB6)

查看:13
本文介绍了用户定义类型 (UDT) 作为类模块 (VB6) 中公共子类中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I've tried to solve this problem, but can't find any solution. I have a UDT defined in a normal module, and wanted to use it as parameter in a Public Sub in a Class Module. I then get a compile error:

Only public user defined types defined in public object modules can be used as parameters or return type for public procedures of class modules or as fields of public user defined types

I then try to move my UDT in the class, declared as Private. I get this compile error:

Private Enum and user defined types cannot be used as parameters or return types for public procedures, public data members, or fields of public user defined types.

I finaly try to declare it as Public in the class, and get this compile error:

Cannot define a Public user-defined type within a private object module.

So is there any way to have a public UDT used as a parameter in a public sub in a class?

解决方案

So is there any way to have a public UDT used as a parameter in a public sub in a class?

In a word, no. The closest you can come with just Classic VB code would be to create a class that replicates the UDT and use that instead. There are definitely advantages there, but you're hosed if you need to pass that to, say, an API as well.

Another option is to define the UDT in a typelib. If you do that, it can be used as a parameter for a public method.

这篇关于用户定义类型 (UDT) 作为类模块 (VB6) 中公共子类中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆