vba - 在 VBA 中声明变量

标签 vba

Dim x, y as Date

这两个代码语句有什么区别
Dim x as Date, y as Date

差异的实际结果是什么?我还缺少哪些其他隐藏的声明功能?

最佳答案

Dim x, y as Date

相当于:
Dim x 
Dim y as Date

这相当于:
Dim x as Variant
Dim y as Date

当您省略变量的类型时,它假定 Variant类型

编辑,根据你的问题:
Dim a! ' same as Dim a as Short
Dim b@ ' same as Dim b as Currency
Dim c# ' same as Dim c as Double
Dim d$ ' same as Dim d as String
Dim e% ' same as Dim e as Integer
Dim f& ' same as Dim f as Long

引用:http://bytes.com/topic/visual-basic/answers/643371-declaration-shortcuts

关于vba - 在 VBA 中声明变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28238292/

相关文章:

Excel VBA - 配置 MS 项目资源表

excel - 列没有不同值时的运行时错误 13

即使退出后,Excel 进程仍在运行

arrays - 循环将值复制到数组中

excel - 在 Microsoft VBA 中的 "if then"循环中使用 "for"语句

html - 使用 VBA 进行网页抓取 - HTMLDocument 对象的早期绑定(bind)与后期绑定(bind)

vba - 使用 VBA 填充 Excel 表单中的动态下拉列表

excel - ActiveWorkbook 与 ActiveWindow

vba - Visio 使用 VBA 更改形状数据/属性

excel - 如何选择特定的 SAP GUI session ?