Vb6 VB str()函数有什么问题?
str()或val()函数的异常行为让我的日子很糟糕,下面的错误让我有2天的时间找到它Vb6 VB str()函数有什么问题?,vb6,Vb6,str()或val()函数的异常行为让我的日子很糟糕,下面的错误让我有2天的时间找到它 temp = Val(currentYear) temp = temp + 1 nextYear = Str(temp) MsgBox "YY" & currentYear & "YY" MsgBox "YY" & nextYear & "YY" 本年度的初始值为“2010年” 结果应该是: YY2010YY YY2011YY 然而,结果是: YY2010YY YY 201
temp = Val(currentYear)
temp = temp + 1
nextYear = Str(temp)
MsgBox "YY" & currentYear & "YY"
MsgBox "YY" & nextYear & "YY"
本年度的初始值为“2010年”
结果应该是:
YY2010YY
YY2011YY
然而,结果是:
YY2010YY
YY 2011YY
这个bug很严重。之后,我在代码旁边添加了一行:
temp = Val(currentYear)
temp = temp + 1
nextYear = Str(temp)
nextYear = LTrim(nextYear)
MsgBox "YY" & currentYear & "YY"
MsgBox "YY" & nextYear & "YY"
然后结果就如预期的那样出现了。有人能解释一下吗?谢谢。您应该改用
CStr
使用空格表示其为正,而CStr
则不为正