I'm trying to write timecode calculation functions for excel.

In the function, the cell that gets passed to the function as the variable TC contains a string in the form hh:mm:ss:ff, where hh is hours, mm is minutes, ss is seconds, and ff is frames (24 frames per second). e.g. "01:23:45:19".

I parse the string into integers for the hours, minutes, seconds and frames.

I want my function to return the total number of frames from 00:00:00:00 as a integer.

Function TC24ToFrames(TC As String) As Integer
Dim F As Integer
Dim S As Integer
Dim M As Integer
Dim H As Integer
F = Int(Right(TC, 2))
S = Int(Mid(TC, 7, 2))
M = Int(Mid(TC, 4, 2))
H = Int(Left(TC, 2))
TC24ToFrames = F + (S * 24) + (M * 24 * 60) + (H * 60 * 60 * 24)
End Function

I get a #VALUE error when I use this. I've texted every part of the function by commenting out sections and the only part that is causing an error is the final calculation.

Does anyone know what is going wrong and how to fix it?