如何在 VB6 中访问隐藏的类变量? [英] How can I access hidden class variables in VB6?

查看:25
本文介绍了如何在 VB6 中访问隐藏的类变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在声明部分有这一行:

I have this line in the declarations section:

Private filePath As String

下面是这样的:

Public Sub Print(filePath As String)  
    ...  
End Sub

在...部分,我想将参数filePath 分配给模块级filePath.但是我怎样才能访问后一个呢?非常感谢.

In the ... part, I want to assign the parameter filePath to the module-level filePath. But how can I get access to the latter one? Thanks a lot.

推荐答案

Phoenie 我不认为在 VB6/VBA 中,一旦你在本地范围内有一些隐藏它的东西(我有一个很好的旧谷歌搜索,但没有出现).如果您想保留命名约定而不更改现有接口,唯一的解决方法是开发一个私有函数来为您访问变量.例如

Phoenie I don't think there's anyway to look at the private class variable in VB6/VBA once you have something in local scope that hides it (I had a good old Google search, but nothing came up). If you want to retain the naming convention and not change the existing interface, the only workaround is to develop a private function to access the variable for you. e.g.

Public Sub Print(filePath As String)

    SetMyFilePath filePath

End Sub

Private Sub SetMyFilePath(ByVal passedFilePath as String)

    filePath = passedFilePath

End Sub

这篇关于如何在 VB6 中访问隐藏的类变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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