## Posted By

oprhu on 03/28/10

# Convert frames (as integer) to correctly formatted video timecode

/ Published in: Other

Takes an integer value of frames (a) and converts it to a text formatted timecode "00:00:00:00" using the supplied framerate (b). Mainly for use in OpenOffice Calc.

`Function FRAMESTOTC(a,b) Dim HrsStr, MinsStr, SecsStr, FramesStr as StringDim HrsFinalStr, MinsFinalStr, SecsFinalStr, FramesFinalStr as StringDim MinsInt, SecsInt, FramesInt as IntegerDim HrsInt as Long 	FramesInt = a mod b	FramesStr = FramesInt	If Len(FramesStr) = 1 Then		FramesFinalStr = "0" & FramesStr	Else		FramesFinalStr = FramesStr	End If  	SecsInt = ((a-FramesInt)/b) mod 60	SecsStr = SecsInt	If Len(SecsStr) = 1 Then		SecsFinalStr = "0" & SecsStr	Else		SecsFinalStr = SecsStr	End If 	MinsInt = ((a-SecsInt*b-FramesInt)/(60*b)) mod 60	MinsStr = MinsInt	If Len(MinsStr) = 1 Then		MinsFinalStr = "0" & MinsStr	Else		MinsFinalStr = MinsStr	End If 	HrsInt = ((a-MinsInt*b*60-SecsInt*b-FramesInt))/(60*60*b) mod 60	HrsStr = HrsInt	If Len(HrsStr) = 1 Then		HrsFinalStr = "0" & HrsStr	Else		HrsFinalStr = HrsStr	End If	 	FRAMESTOTC =  HrsFinalStr & ":" & MinsFinalStr & ":" & SecsFinalStr & ":" & FramesFinalStr End Function`