有没有办法在vb6中预定义一个字符串?

时间:2012-02-15 11:14:09

标签: string vb6 predefined-variables

我正在尝试类似的事情:

Dim experiment As String = "Predefined experiment string.."

但遗憾的是它没有用,所以有没有办法在vb6中以类似的方式重新定义字符串?

2 个答案:

答案 0 :(得分:8)

对于常量字符串:

const experiment As String = "Predefined experiment string.."

在模块/类/表单的顶部,带有相应范围的访问修饰符,或者作为本地例程。

对于具有可变内容的字符串,您无法在同一行声明和分配,但是:

Dim experiment As String: experiment = "Predefined experiment string.."

答案 1 :(得分:3)

您在一个声明中做了两件事:声明变量初始化它。

在VB6中,您必须分别执行以下操作:

Dim experiment As String 
experiment = "Predefined experiment string.."
相关问题