Excel VBA错误:类型不匹配(错误 13)

Excel VBA错误:类型不匹配(错误 13):当前 Visual Basic为了完成数据类型的赋值,能够对许多数值进行转换,而较早的版本则做不到。然而,此错误仍可能发生并且有 下列几种原因和解决方法: Excel VBA Error: Type mismatch (error 13): the current Visual Basic to complete the data type of assignment, the value can be converted to many, but earlier versions can not. However, this error may still occur and there are several causes and solutions: 1、变量或属性类型错误。例如,一个整型值的变量不能赋给字符串值,除非整个字符串可识别成为整型。 1, variable or attribute type errors. For example, an integer value of the variable can not be assigned a string value, unless the entire string can be identified as an integer. 尽量在兼容的数据类型间赋值。例如,Integer 可以被赋给 Long,Single 可以被赋给 Double,而任何类型(除了用户类型)可以赋给 Variant。 As far as possible between compatible data types assignment. For example, Integer can be assigned to Long, Single can be assigned to Double, and any type (except the user types) can be assigned to Variant. 2、将对象传给了需要单一属性或值的过程。 2, the object passed to the need for a single property or value of the process. 传递正确的单一属性或调用给工程的方法。 Pass the correct call to a single property or method of construction. 3、使用了表达式所要的模块或工程名称,例如: 3, the use of the expression to be a module or project name, for example: Debug.Print MyModule 指定可以显示的表达式。 You can display the specified expression. 4、将传统 Basic 错误处理例程与拥有 Error 子类型 (10, vbError) 的 Variant 值混合,例如: 4, the traditional error-handling routines and have a Basic Error subtype (10, vbError) a Variant value mixed, for example: Error CVErr(n) 识别一个错误,要将其映射到 Visual Basic 或用户错误,然后产生错误。 Identify an error, to map it to a Visual Basic or user error, then error. 5、CVErr 值不能转换成 Date。例如: 5, CVErr value can not be converted into a Date. For example: MyVar = CDate(CVErr(9)) 使用 Select Case 语句或一些类似的结构映射返回的 CVErr。 Use a Select Case statement or some similar structure mapping returned CVErr. 6、在运行时,此错误通常说明在无效子类型的表达式中使用了 Variant,或 包含数组的 Variant 中出现了 Print # 语句。可用循环显示每个元素以打印数组。 6, at run time, this error usually indicates an invalid subtype expression in the use of a Variant, or Variant containing an array appears in the Print # statement. Cycle through each element can be used to print the array.
失败是什么?没有什么,只是更走近成功一步;

Excel VBA错误:类型不匹配(错误 13)

相关文章:

你感兴趣的文章:

标签云: