我的功能:
Option Explicit
Public Function hmsa(h1 As Integer,m1 As Integer,s1 As Integer,h2 As Integer,m2 As Integer,s2 As Integer)
Dim hr1,min1,sec1,hr2,min2,sec2,h,m,s As Integer
Dim scf,mcf,hcf As Boolean
scf = mcf = hcf = False
hr1 = h1
min1 = m1
sec1 = s1
hr2 = h2
min2 = m2
sec2 = s2
Dim r,c As Single
r = activeCell.Row
c = activeCell.Column
s = sec1 + sec2
If s >= 60 Then
scf = True
s = s - 60
Else
scf = False
End If
m = min1 + min2
If scf = True Then
m = m + 1
End If
If m >= 60 Then
mcf = True
m = m - 60
Else
mcf = False
End If
h = hr1 + hr2
If mcf = True Then
h = h + 1
End If
If h >= 24 Then
hcf = True
h = h - 24
Else
hcf = False
End If
' MsgBox "h:" & h & " m:" & m & " s:" & s,vbOKOnly,"DEBUG"
printhms h,s,r,c
End Function
以及用于打印值的子程序
Public Sub printhms(ByRef hr As Integer,ByRef mn As Integer,ByRef se As Integer,ByRef r As Integer,ByRefc As Integer)
activeSheet.Cells(r,c).Value = se
activeSheet.Cells(r,c).Offset(-1,0).Value = mn
activeSheet.Cells(r,c).Offset(-2,0).Value = hr
End Sub
我在函数中收到此错误:
编译错误:ByRef 参数类型不匹配