Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB.Net with MSAccess

Status
Not open for further replies.

Domino2

Technical User
Jun 8, 2008
475
GB
I have an access database which was working okay, until MS came along and made the MSComm control unsupported. I was using it to talk to the serial port to get timecodes from video tape machines. I have been looking at rebuilding the database in VB.Net using MySql, however I wondered if its possible to embed a vb application into access to replace tha function. Any suggestions appreciated as a real headache caused by big brother.
 
You can make a com dll in VB.Net that Access can use. I did it for an email process we have. VS2005 had a template for that very thing. I don't see it for VS2008 or they renamed it something else.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Thanks, I am using Visual Basic Express 2008 so I don't know if I can do it with that. Any ideas where I can find out how I create a com.dll. Something I have never done or got near to. Regards
 
Just thought I also have VB6 standard version as well.
 
You should be able to do it you might just have to do some of the steps manually then. Try doing a search on MSDN or Google I can't find any of the links I had on it.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
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
 
I have just been playing with VB6. Would I be going in the wrong direction if I make the above into an activex control? Would it be legal to use the MSComm6 control in this manner and would an ActiveX control work. Struggling, thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top