Many thanks Sorwen. I thought I would put up the code from the access database in case someone can point me how this could be done in VB.Net using a different control in case MS takes the MSComm 6 control off the face of the planet.
There are two buttons, 1 to get a start timecode from a VTR and one to get the end timecode. Sorry its a bit long (full of calculations of time syntax code, but basically I just want to get two values back, stsrt and end.
Private Sub Command127_Click()
' This is the button requesting the timecode start value from VTR
inpclear = MSComm1.Input
MSComm1.Output = Chr$(&H61) & Chr$(&HC) & Chr$(&H3) & Chr$(&H70)
Me.TimerInterval = intWait
intResendCount = 0 'Start of max. of 5 resend requests
intStart = 1
End Sub
Private Sub Command128_Click()
' This button requests timecode end
' Get timecode end value and duration
inpclear = MSComm1.Input
MSComm1.Output = Chr$(&H61) & Chr$(&HC) & Chr$(&H3) & Chr$(&H70)
Me.TimerInterval = intWait
intResendCount = 0 'Start of max. of 5 resend requests
intStart = 0
Exit Sub
Private Sub Form_Timer()
Dim I As Integer, j As Integer, intCsum As Integer, intFailed As Integer, intTC
Dim longStartTCarray(3) As Long, longEndTCarray(3) As Long, longDurationarray(3) As Long
Dim longStartTC As Long, longEndTC As Long, longDuration As Long
Dim intFR As Long 'Frame rate
Dim strInstring As String, strDuration As String
Dim strStandard As String
Dim strFrames$, strSecs$, strMins$, strHrs$
On Error GoTo TCReqResend
intFailed = 1 'Presume failure.
intCsum = 0
For I = 0 To 5 'Calculate checksum
intCsum = intCsum + inp(I)
Next
intCsum = intCsum Mod 256 'Make checksum less than 256!
If intCsum = inp(6) Then 'If checksum is valid.
intFailed = 0 'Valid checksum. Not failed.
'Mask out status bits.
inp(2) = inp(2) And &H3F 'Frames.
inp(3) = inp(3) And &H7F 'Seconds
inp(4) = inp(4) And &H7F 'Minutes
inp(5) = inp(5) And &H37 'Hours
strFrames = Right("00" & Trim(STR(Hex(inp(2)))), 2)
strSecs = Right("00" & Trim(STR(Hex(inp(3)))), 2)
strMins = Right("00" & Trim(STR(Hex(inp(4)))), 2)
strHrs = Right("00" & Trim(STR(Hex(inp(5)))), 2)
strInstring = strHrs & ":" & strMins & ":" & strSecs & ":" & strFrames 'Create timecode string
' COMES HERE TO GET TIMECODE START VALUE
If intStart = 1 Then
Me.TCStart = strInstring
strStartTC = strInstring
Else
Me.TCEnd = strInstring
strEndTC = strInstring
End If
On Error GoTo ErrorReturn
' =============================================================
If strStartTC <> "" And strEndTC <> "" Then 'If start and end TC exist
' Calculate duration
j = 0
For I = 1 To Len(strStartTC) 'Split TC string into hours, minutes, seconds & frames as long integers.
If Mid$(strStartTC, I, 1) <> ":" Then
longStartTCarray(j) = 10 * longStartTCarray(j) + Val(Mid$(strStartTC, I, 1))
Else
j = j + 1
End If
Next I
j = 0
For I = 1 To Len(strEndTC) 'Split TC string into hours, minutes, seconds & frames as long integers.
If Mid$(strEndTC, I, 1) <> ":" Then
longEndTCarray(j) = 10 * longEndTCarray(j) + Val(Mid$(strEndTC, I, 1))
Else
j = j + 1
End If
Next I
' 'If tape standard is PAL (625/50)
strStandard = "PAL"
If strStandard = "PAL" Then
intFR = 25
Else
intFR = 30 'Non drop
End If
'Turn hours, minutes, seconds & frames into frames
longStartTC = longStartTCarray(0) * 60 * 60 * intFR + longStartTCarray(1) * 60 * intFR + longStartTCarray(2) * intFR + longStartTCarray(3)
longEndTC = longEndTCarray(0) * 60 * 60 * intFR + longEndTCarray(1) * 60 * intFR + longEndTCarray(2) * intFR + longEndTCarray(3)
If longEndTC >= longStartTC Then
longDuration = longEndTC - longStartTC
Else
longDuration = -1
End If
If longDuration >= 0 Then 'If duration is non negative create duration TC string from the hours, minutes, seconds & frames.
longDurationarray(0) = Int(longDuration / (60 * 60 * intFR)) 'Hours
longDuration = longDuration - longDurationarray(0) * 60 * 60 * intFR 'Find remainder
longDurationarray(1) = Int(longDuration / (60 * intFR)) 'Minutes
longDuration = longDuration - longDurationarray(1) * 60 * intFR 'Find remainder
longDurationarray(2) = Int(longDuration / intFR) 'Seconds
longDuration = longDuration - longDurationarray(2) * intFR 'Find remainder
longDurationarray(3) = longDuration 'Frames
'Create duration timecode string
'strDuration = Str$(longDurationarray(0)) & ":" & Str$(longDurationarray(1)) & ":" & Str$(longDurationarray(2)) & ":" & Str$(longDurationarray(0))
strFrames = Right("00" & Trim(STR(longDurationarray(3))), 2)
strSecs = Right("00" & Trim(STR(longDurationarray(2))), 2)
strMins = Right("00" & Trim(STR(longDurationarray(1))), 2)
strHrs = Right("00" & Trim(STR(longDurationarray(0))), 2)
strDuration = strHrs & ":" & strMins & ":" & strSecs & ":" & strFrames 'Create timecode string
Else
strDuration = "Negative"
End If
' DURATION PUT IN DATABASE FIELD HERE
' ===============================================================
' CODE COMES HERE AFTER TIMECODE START AND END VALUES HAVE BEEN GOT, AND AFTER CALCULATING DURATION
Me.TCDuration.SetFocus
Me.TCDuration = strDuration
Me.Dummy.SetFocus
ErrorReturn:
End If
Me.TimerInterval = 0 'Not failed. Cancel timer
End If
TCReqResend:
If intFailed = 1 Then
intResendCount = intResendCount + 1
If intResendCount < 5 Then
'MSComm1.Output = Chr$(&H61) & Chr$(&H0C) & Chr$(&H03) & Chr$(&H70) 'Resend timecode request
inpclear = MSComm1.Input 'Clear any pending interrupts
MSComm1.Output = Chr$(&H61) & Chr$(&HC) & Chr$(&H3) & Chr$(&H70) 'Resend timecode request
Else
MsgBox ("VTR either not present or not in remote")
Me.TimerInterval = 0
End If
End If
If intStart = 1 Then
' CODE COMES ON TIMECODE START VALUES BEING FINISHED
' Disable timcode start textbox as filled with TC start value
'Me.Dummy.SetFocus
'Me.TCStart.Enabled = False: Me.TCStart.Locked = True
'Me.Label95.Visible = False
'Me.Comments.Enabled = True: Me.Comments.Locked = False
'Me.Shot.Enabled = True: Me.Shot.Locked = False
'Me.StarRating.Enabled = True: Me.StarRating.Locked = False
'Me.Comments.SetFocus
' Now returns to code that sent it here
Else
' CODE COMES ON TIMECODE START, END AND DURATION VALUES BEING FINISHED
' Disable timcode end textbox as filled with TC end value, and duration filled
' Me.Dummy.SetFocus
' Me.TCEnd.Visible = True: Me.TCEnd.Enabled = False: Me.TCEnd.Locked = True
' Me.TCDuration.Visible = True: Me.TCDuration.Enabled = False: Me.TCDuration.Locked = True
' Now returns to code that sent it here
End If
End Sub