请教:为什么会出现类型不匹配?
在VBA中如下代码:
Dim RowCounter As Long
RowCounter = Worksheets(1).UsedRange.Rows.Count()
Dim RowCycle As Long
Dim ActiveCell As Range
Dim AgeRange As Range
Dim SexRange As Range
Dim Age As Integer
Dim YearCount As Integer
For RowCycle = 1 To RowCounter
Set ActiveCell = Worksheets(1).Range("AI" & (RowCycle + 1))
Set AgeRange = Worksheets(1).Range("E" & (RowCycle + 1))
Set SexRange = Worksheets(1).Range("D" & (RowCycle + 1))
Age = CInt(Format(AgeRange, "yyyymmdd") / 10000) //这条语句出现类型不匹配
If (SexRange.Text = "男" & Age <= 1947) Then YearCount = Age - 1932
If (SexRange.Text = "女" & Age <= 1952) Then YearCount = Age - 1932
If (YearCount >= 0) Then ActiveCell.Value = CLng(YearCount * 1300) + CLng(15000) Else ActiveCell.Value = 15000
Next RowCycle
如上面代码,在调试中可以执行,但是在上面Age那一行出现“类型不匹配”的提示,请问是为什么呢?应该怎么修改?
谢谢大家~!
Dim RowCounter As Long
RowCounter = Worksheets(1).UsedRange.Rows.Count()
Dim RowCycle As Long
Dim ActiveCell As Range
Dim AgeRange As Range
Dim SexRange As Range
Dim Age As Integer
Dim YearCount As Integer
For RowCycle = 1 To RowCounter
Set ActiveCell = Worksheets(1).Range("AI" & (RowCycle + 1))
Set AgeRange = Worksheets(1).Range("E" & (RowCycle + 1))
Set SexRange = Worksheets(1).Range("D" & (RowCycle + 1))
Age = CInt(Format(AgeRange, "yyyymmdd") / 10000) //这条语句出现类型不匹配
If (SexRange.Text = "男" & Age <= 1947) Then YearCount = Age - 1932
If (SexRange.Text = "女" & Age <= 1952) Then YearCount = Age - 1932
If (YearCount >= 0) Then ActiveCell.Value = CLng(YearCount * 1300) + CLng(15000) Else ActiveCell.Value = 15000
Next RowCycle
如上面代码,在调试中可以执行,但是在上面Age那一行出现“类型不匹配”的提示,请问是为什么呢?应该怎么修改?
谢谢大家~!
...全文
相关推荐
泛型编程深度解析:为什么你的C#代码总提示类型不匹配?.pdf
它不仅支持多种编程风格,包括命令式、函数式以及并发编程,还提供了强大的安全性和类型安全性。借助于 .NET
Android 中IntentFilter的匹配规则实例详解
如果没有 category 的话,这个 Intent 仍然可以匹配成功(这点和 action 不同)。至于为什么不设置 category 也能匹配?
数组:为什么很多编程语言中数组都从0开始编号?.pdf
### 数组:为什么很多编程语言中数组都从0开始编号?#### 一、数组的基本概念数组是一种线性表数据结构,它使用一组连续的内存空间来存储一系列具有相同类型的数据。这一定义中有几个关键点:1.
出错的正则文本,不知道为什么
### 题目解析:为什么正则表达式会因为文本的微小变化而失效?#### 1.
noop-loader:Webpack加载器什么都不做
= { module: { rules: [ { test: /\.jsx?


