VB6 中未设置的变体的默认值是什么? [英] What is the default value for an unset variant in VB6?

查看:11
本文介绍了VB6 中未设置的变体的默认值是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一些旧代码,它定义了一个像这样的全局变量...

I am working with some old code and it defines a global variable like this...

Public myvar

这个变量永远不会被赋值,但后来在测试中使用......

This variable is never assigned a value, but is later used in a test...

If myvar <> somevalue then
    'do something
End If

对于 somevalue 的什么值会做某事?

For what values of somevalue would that something be done?

推荐答案

  • 默认值为 Empty.
  • 对于除 Empty0"" 之外的任何值都将完成某事"...
    • ... 对于 Nothing 值,代码将引发错误并且某些事情将无法完成".
      • The default value is Empty.
      • "Something will be done" for any value except Empty, 0 or ""...
        • ... for the value Nothing, the code will raise an error and "something will not be done".
        • 来自 VB6 文档

          当变量被初始化时,一个数值变量初始化为 0,可变长度字符串是初始化为长度为零的字符串(""),一个固定长度的字符串是用零填充.变体变量被初始化为空.每个元素一个用户定义的类型变量是初始化就好像它是一个单独的变量.

          When variables are initialized, a numeric variable is initialized to 0, a variable-length string is initialized to a zero-length string (""), and a fixed-length string is filled with zeros. Variant variables are initialized to Empty. Each element of a user-defined type variable is initialized as if it were a separate variable.

          这篇关于VB6 中未设置的变体的默认值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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