为什么传参数时出错

Amy-zhang 2007-01-05 03:01:54
Private Sub loopMonthRow(fst_date_mm, fst_date_dd, last_date_mm, last_date_dd As String, row_no As Integer)
loopToFstMonthOrDate fst_date_mm & STR_MONTH_NM, INT_ROW_MONTH
loopToFstMonthOrDate fst_date_dd , INT_ROW_DATE

End Sub

Private Sub loopToFstMonthOrDate(content As String, row As Integer)
。。。
End Sub

当我执行loopMonthRow这个方法时总是报错
loopToFstMonthOrDate fst_date_dd , INT_ROW_DATE
中的fst_date_dd参数“BYREF参数类型不匹配”,但是当我改成
loopToFstMonthOrDate fst_date_dd & "", INT_ROW_DATE以后就对了。这是社呢们原因啊,应该怎么处理啊
...全文
193 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zqsntws 2007-01-10
  • 打赏
  • 举报
回复
建议楼主定义变量时要显示指定类型,否则容易出错
clear_zero 2007-01-10
  • 打赏
  • 举报
回复
“如果
将loopMonthRow(fst_date_mm, fst_date_dd, last_date_mm, last_date_dd As String, row_no As Integer)
中的参数也都显式声明,”
难道我这里的参数不是显式声明吗?

fst_data_mm,fst_date_dd,last_date_mm的数据类型是什么?
zqsntws 2007-01-10
  • 打赏
  • 举报
回复
fst_date_mm我就不知道是什么类型的变量
Amy-zhang 2007-01-10
  • 打赏
  • 举报
回复
“如果
将loopMonthRow(fst_date_mm, fst_date_dd, last_date_mm, last_date_dd As String, row_no As Integer)
中的参数也都显式声明,”
难道我这里的参数不是显式声明吗?
Amy-zhang 2007-01-10
  • 打赏
  • 举报
回复
那在定义变量时,如何显式或隐式指定变量的类型啊
VBToy 2007-01-05
  • 打赏
  • 举报
回复
loopToFstMonthOrDate(content As String, row As Integer)中的参数类型是显式声明的,如果
将loopMonthRow(fst_date_mm, fst_date_dd, last_date_mm, last_date_dd As String, row_no As Integer)
中的参数也都显式声明,且与调用loopToFstMonthOrDate时传递的参数类型一值。fst_date_dd & ""相当如将fst_date_dd 强制转换成了字符串型,与 loopToFstMonthOrDate中的参数类型一致,所以不会报错。

2,506

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧