Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 22nd, 2005, 11:36 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
Coding String from Com Port into Access

I am trying to capture a String from the Com Port and bring that string into Access.....I have hooked the GPS Unit up to the Com Port and can read the string from inside HyperTerminal. Does anyone have any sample code or any thoughts to the code I have below. This code was also donated (Thanks nofriends). I thank you all for your help.

The $GPGGA is the leading characters from the NMEA Sentence Information

I have a form set up in Access that retrieves data from a database, allows the user to input new records etc. Can I place this code in the code window of that form?

I thought of writing that to a seperate function and calling it "On Click". Does that make sense?


CODE:

Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent

Case "$GPGGA"
buffer = MSComm1.Input
MsgBox StrConv(buffer, vbUnicode)
Case Else
MsgBox "Unknown error or event"
End Select
End Sub

Reply With Quote
  #2  
Old August 22nd, 2005, 11:56 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
Coding String from Com Port into Access

I am not sure I have the right Object Library turned on....Does anyone know what Object LIbrary I should activate.

I thank you for your help....I am very new to this....

Reply With Quote
  #3  
Old August 22nd, 2005, 11:56 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
is it showing the Unkown error or event msg the whole time?

the input will look something like this?

$GPGGA bla bla bla
__________________
Look! Its a ShemZilla



Reply With Quote
  #4  
Old August 22nd, 2005, 12:09 PM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
Hi Jay,
I only have the comm control on my form,
do you have something like this in the form_load event?
its to initialize and open the comm port:
Code:
if (Not MSComm0.PortOpen) Then
       
        ' Buffer to hold input string
            Dim Instring As String
        ' Use COM1.
            MSComm0.CommPort = 1
        ' 9600 baud, no parity, 8 data, and 1 stop bit.
            MSComm0.Settings = "9600,N,8,1"
        ' Tell the control to read entire buffer when Input is used.
            MSComm0.InputLen = 0
        ' Open the port.
            MSComm0.PortOpen = True
        ' Send the attention command to the modem.
            MSComm0.Output = "AT" & vbCr ' Ensure that the modem responds with "OK".
        ' Wait for data to come back to the serial port.
            Buffer$ = Buffer$ & MSComm0.Input      
            
            
            MsgBox "SMS Port Open", vbOKOnly, "Port State"
    Else
        MsgBox "SMS Port Already Open", vbOKOnly, "Port State"
    End If

make sure that you have something like this on load so that it gets opened and initiliazed

Reply With Quote
  #5  
Old August 22nd, 2005, 12:13 PM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
and have something like this in the onComm event:
Code:
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
            
            Case comEvReceive
                Buffer = MSComm1.Input
                  If InStr(Buffer, "$GPGGA") > 0 Then 'check to see if the command has $GPGGA  in front
			msgbox Buffer
                  End If
            Case Else
               MsgBox "Unknown error or event"
    End Select
End Sub

you must use event in the case, that the actual input, and then use
instr to check if that pre-leading chars are there.

hope this helps

Reply With Quote
  #6  
Old August 22nd, 2005, 12:18 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
Code String from Com Port

When I place this code into my ACCESS FORM, below all my other code I dont get anything. Nothing happens....

Input :

$GPGGA,17034,456345.8976,N,345646,W,1,05,280.2,M,-34.0,M,,,*75

There should be a total of 14 commas....

I should be good placing this code write in the Code Window in my form right?

Reply With Quote
  #7  
Old August 22nd, 2005, 12:21 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
Coding

Do I need to set up the Settings below and Open the port?

What about clearing the port....do you know how this is accomplished

Code:

MSComm.Settings = "9600, n, 8 , 1"
MSComm.CommPort = 1
PortStatus = MSComm.PortOpen
If Not PortStatus = True Then
MSComm.PortOpen = True
End If

Reply With Quote
  #8  
Old August 22nd, 2005, 12:23 PM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
hi, put the first section in the form load event, in the code window, and double click on the comm control, then it should take you to the on_Comm event and place the 2nd section of code there.

that should do the trick

Reply With Quote
  #9  
Old August 22nd, 2005, 12:24 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
I created a MODULE in Access and place the code in there. I am not getting error when I run teh Module...

Run Time Error '424'
Object Required.

Could this be a result of not having the correct Object Library loaded?

Reply With Quote
  #10  
Old August 22nd, 2005, 12:26 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
Ok Ill Try That

Reply With Quote
  #11  
Old August 22nd, 2005, 12:26 PM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107973 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
Jay, I have only limited experience in this, only started with a project and left it

You'll need to open the port in the code using the code you posted, that should go in the form load event.

hope this helps

Reply With Quote
  #12  
Old August 22nd, 2005, 12:53 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
I placed your Com Port code in my Form under Form Load event and I am getting the same error.....this is all the code I have sitting on my Form. I commented all the code in the form load except for the Msg Box and that came out fine. SO to problem that is occuring is inthe first line of code. Thats where my debuger keeps bring me back to which is prety vague....I think it does not like "MSComm0.PortOpen"


Run Time Error '424'
Object Required.

I cannot thank you enough for your help here.....I am really stuck.....I have ben trying to find information on this and cant seem to find it. I despertaly want to learn this and am learning a lot.....

CODE:

Option Compare Database

Private Sub Form_Load()
If (Not MSComm0.PortOpen) Then

' Buffer to hold input string
Dim Instring As String
' Use COM1.
MSComm0.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm0.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input is used.
MSComm0.InputLen = 0
' Open the port.
MSComm0.PortOpen = True
' Send the attention command to the modem.
MSComm0.Output = "AT" & vbCr ' Ensure that the modem responds with "OK".
' Wait for data to come back to the serial port.
Buffer$ = Buffer$ & MSComm0.Input


MsgBox "SMS Port Open", vbOKOnly, "Port State"
Else
MsgBox "SMS Port Already Open", vbOKOnly, "Port State"
End If
End Sub

'_________________________________________________

Private Sub MSComm1_OnComm()

'Attempting to Return a value from the port
Select Case MSComm1.CommEvent

Case "$GPGGA"
'writing the return to the buffer variable from the Comm Port
Buffer = MSComm1.Input
If InStr(Buffer, "$GPGGA") > 0 Then
' Converting the return so I can read it
MsgBox StrConv(Buffer, vbUnicode)
Case Else
MsgBox "NO DEAL"

End Select

End Sub

Reply With Quote
  #13  
Old August 22nd, 2005, 12:55 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5