【发布时间】:2015-03-29 20:39:26
【问题描述】:
我不断收到 ByRef 错误,但我似乎无法弄清楚。 代码全部写在同一个模块中。
Sub GetTime(Labelname As Object)
Dim Hint, Mint, Sint As Integer
Dim time As String
Hint = CInt(Hour(Now))
Mint = CInt(Minute(Now))
Sint = CInt(Second(Now))
time = CorrectTime(Hint, Mint, Sint)
Private Function CorrectTime(Hours As Integer, Minutes As Integer, Seconds As Integer) As String
Dim HS, MS, SS As String
If Len(CStr(Hours)) = 1 Then
HS = "0" & CStr(Hours)
Else
HS = CStr(Hours)
End If
If Len(CStr(Minutes)) = 1 Then
MS = "0" & CStr(Minutes)
Else
MS = CStr(Minutes)
End If
If Len(CStr(Seconds)) = 1 Then
SS = "0" & CStr(Seconds)
Else
SS = CStr(Seconds)
End If
CorrectTime = HS & ":" & MS & ":" & SS
End Function
每当我尝试运行代码时,它都会给我一个错误
time = CorrectTime(Hint, Mint, Sint)
错误类型将是 ByRef 不匹配。
我没有看到什么可以解决这个问题?
【问题讨论】:
-
顺便说一句,你应该使用
Long而不是Integer