简体   繁体   English

类型不匹配错误(vba)

[英]Type mismatch error (vba)

I get Type mismatch error in the last line of this part of code: 我在这部分代码的最后一行中收到Type mismatch错误:

Dim test As Object
Set test = Mid(Trim(row.Cells(1, 19).Value), 9, 1) Mod 2

How can I resolve it? 我该如何解决?

There is no type hierarchy in VBA, an Object is for object instances, it cannot hold primitive types. VBA中没有类型层次结构,一个Object用于对象实例,它不能保存原始类型。

Use a Long 使用Long

Dim test As long
test = Mid(Trim(row.Cells(1, 19).Value), 9, 1) Mod 2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM