将多个对象缩小为整数/变体/等等? [英] Dim multiple objects as Integer / Variant / etc.?

查看:116
本文介绍了将多个对象缩小为整数/变体/等等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Can I dim multiple objects as integers in 1 line in this concise fashion, or does this make only d be an Integer?

我可以以简洁的方式将多个对象以1行整数淡入淡入淡出吗? c> Dim a,b,c,d As Integer

Dim a, b, c, d As Integer


推荐答案

您可以测试:

Sub test()
    Dim a, b, c, d As Integer
    Debug.Print TypeName(a)
    Debug.Print TypeName(b)
    Debug.Print TypeName(c)
    Debug.Print TypeName(d)
End Sub

立即窗口中的输出:

Empty
Empty
Empty
Integer

空的可能有点混乱,但是它清楚地表明只有最后一个是整数。使用F8来执行代码,在查看局部窗口中的结果时更加翔实,因为a,b,c的类型被明确地表示为Variant / Empty。

The empty might be slightly confusing, but it makes it clear that only the last is an integer. Using F8 to step though the code, while viewing the results in the Locals Window is even more informative since then the types of a,b,c are explicitly given as Variant/Empty.

这篇关于将多个对象缩小为整数/变体/等等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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