什么VB6方法允许两个相同类型的自定义对象(在类模块中定义)相互比较?我认为这与
Java的compareTo方法相当,但我无法在任何地方找到它.
解决方法
如果通过“比较”表示“它们是同一类型吗?”,您可以使用TypeName函数:
If (object1 <> Nothing) and (object2 <> Nothing) then If (TypeName(object1) = TypeName(object2)) Then Debug.Print "object types are the same" Else Debug.Print "object types are NOT the same" End If End If
如果通过“比较”表示“它们是否在内存中引用相同的对象?”,则可以使用Is运算符:
If (object1 Is object2) Then Debug.Print "objects references are the same" Else Debug.Print "objects references are NOT the same" End If
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。