Go Back   CodeCall Programming Forum > Software Development > Visual Basic Programming
Register Blogs Search Today's Posts Mark Forums Read

Visual Basic Programming Discussion forum for Visual Basic, an event driven programming language and associated development environment from Microsoft for its COM programming model.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-01-2009, 05:22 PM
Newbie
 
Join Date: Jun 2009
Posts: 8
camolas is an unknown quantity at this point
New in vb need help in array

Hi,

Im a hobiest in all that is microcontrolers, pcs, carpcs........ ok i star last year in pic basic pro (microcontroler language) made nice things on that.
Now im to put this vb to work with a gps usb receiver to get: lat, long, speed, n of sats,... but can do it. Can you vb masters help me?

Code:
'Reads GPS
Public Sub ReadGPSInfo(ByVal sData As String, Optional CommaSys As Boolean = True)
Static Ltry As Double   'Last Time we tried to reconnect GPS
Static Buff As String   'Buffer of Data
Dim Nb As Long          'Number of Bytes
Dim b() As Byte         'Array of Bytes
Dim DT() As String      'GPS Fields

On Error Resume Next
    'If nothing to do
    If sData = "" Then
        Exit Sub
    Else
            '<<<<<<<<<<< ADD BY MSCAR >>>>>>>>>>>>>>>
            'GPSLog sData ' log to a file
            '>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<
            
            'Process Line of Data
            If Left(sData, 1) = "$" Then
                DT = Split(sData, ",")
            
                'Save latest messages to Log in case somebody wants it later
                'NMEAMSGs.Remove DT(0)
                'NMEAMSGs.Add sData, DT(0)
                
                Select Case DT(0)
                    Case "$GPRMC"
                        'Get Lat, Long, Speed and Heading
                        GPS.Lat = CDbl(Left(DT(3), InStr(1, DT(3), ".") - 1))
                        GPS.Lon = CDbl(Left(DT(5), InStr(1, DT(5), ".") - 1))
                        If CommaSys Then
                            'Prepare for Conversions
                            If CommaSys Then DT(3) = Replace(DT(3), ".", ",")
                            If CommaSys Then DT(5) = Replace(DT(5), ".", ",")
                            If CommaSys Then DT(7) = Replace(DT(7), ".", ",")
                            If CommaSys Then DT(8) = Replace(DT(8), ".", ",")
                            'Get Lat/Long
                            GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ",") - 2)) / 60#)
                            GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ",") + -2)) / 60#)
                        Else
                            GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ".") - 2)) / 60#)
                            GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ".") + -2)) / 60#)
                        End If
                        If DT(4) = "S" Then GPS.Lat = -GPS.Lat
                        If DT(6) = "W" Then GPS.Lon = -GPS.Lon
                        GPS.Speed = CDbl(DT(7))
                        If GPS.Speed > 3 Then GPS.Hdg = CInt(DT(8))
                        'If set time from GPS then
                        'If GPSTime And GPS.Valid Then
                        '    'Check for Inverted Date format (stupid GPSs in US date format -- nonstandard)
                        '    DT(0) = "": DT(0) = UseVars("gpsusadate")
                        '    If LCase(DT(0)) = "true" Then DT(9) = Mid(DT(9), 3, 2) + Left(DT(9), 2) + Mid(DT(9), 5)
                        '
                        '    'If time OR date is wrong, set it correctly from GPS
                        '    If Format(DateAdd("h", TimeZone, Now), "HHMM") <> Left(DT(1), 4) Or Format(DateAdd("h", TimeZone, Now), "DDMMYY") <> DT(9) Then
                        '        DT(1) = Format(DateAdd("h", -TimeZone, Mid(DT(9), 3, 2) + "/" + Left(DT(9), 2) + "/" + Mid(DT(9), 5, 2) + " " + Left(DT(1), 2) + ":" + Mid(DT(1), 3, 2) + ":" + Mid(DT(1), 5, 2)), "MM/DD/YY HH:MM:SS")
                        '        Date = Left(DT(1), 8)
                        '        Time = Mid(DT(1), 10)
                        '    End If
                        'End If
                    Case "$GPGGA"
                        'Get Altitude and Sat Count
                        If CommaSys Then DT(9) = Replace(DT(9), ".", ",")
                        GPS.Alt = CDbl(DT(9))
                        GPS.Sats = CInt(DT(7))
                        GPS.Valid = (Val(DT(6)) > 0)
                        
                End Select
            End If
End If
End Sub
I want to parch the data and display as a normal gps displays. but is a all mess i think this lines are no good.
Code:
  GPS.Lat = CDbl(Left(DT(3), InStr(1, DT(3), ".") - 1))
                        GPS.Lon = CDbl(Left(DT(5), InStr(1, DT(5), ".") - 1))
                        If CommaSys Then
                            'Prepare for Conversions
                            If CommaSys Then DT(3) = Replace(DT(3), ".", ",")
                            If CommaSys Then DT(5) = Replace(DT(5), ".", ",")GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ",") - 2)) / 60#)
                            GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ",") + -2)) / 60#)
                        Else
                            GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ".") - 2)) / 60#)
                            GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ".") + -2)) / 60#)
what thas this lines do? please comment them.
Thanks for the help

Last edited by Jaan; 07-02-2009 at 11:00 AM.. Reason: Please use code tags when you are posting your codes!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-01-2009, 06:24 PM
Vswe's Avatar
Code Slinger
 
Join Date: Apr 2009
Location: Uppsala, Sweden
Age: 16
Posts: 8,536
Vswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond repute
Send a message via MSN to Vswe Send a message via Skype™ to Vswe
Re: New in vb need help in array

Which vb is this? VB.NET? VB6? Other?
__________________
My CC Blog | My Website |Periodic table | Pm me | Ask me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-01-2009, 07:26 PM
Newbie
 
Join Date: Jun 2009
Posts: 8
camolas is an unknown quantity at this point
Re: New in vb need help in array

Hi,

Is VB6, please help me on this im 2 months and cant get it.

Thanks for the help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-02-2009, 05:34 AM
Vswe's Avatar
Code Slinger
 
Join Date: Apr 2009
Location: Uppsala, Sweden
Age: 16
Posts: 8,536
Vswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond repute
Send a message via MSN to Vswe Send a message via Skype™ to Vswe
Re: New in vb need help in array

I'm not so familiar with VB6 so I can't check if these lines are correct but if they are they doing this:

Code:
GPS.Lat = CDbl(Left(DT(3), InStr(1, DT(3), ".") - 1)) 'Adds the value before the dot in DT(3) to GPS.Lat
GPS.Lon = CDbl(Left(DT(5), InStr(1, DT(5), ".") - 1)) 'Adds the value before the dot in DT(5) to GPS.Lon
If CommaSys Then 'If CommaSys is True
    'Prepare for Conversions
    If CommaSys Then DT(3) = Replace(DT(3), ".", ",") 'If CommaSys is True, replace all dots in DT(3) with commas.
    If CommaSys Then DT(5) = Replace(DT(5), ".", ",")GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ",") - 2)) / 60#) 'If CommaSys is True, replace all dots in DT(5) with commas and GPS.Lat's value is dividied with 100 and then the value of DT(3) which is before the comma is dividied with 60 and added to GPS.Lat.
    GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ",") + -2)) / 60#) 'GPS.Lon is dividied with 100 and the value of DT(5) before the comma is dividied with 60 and the added to GPS.Lon
Else 'If CommaSys is False
    GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ".") - 2)) / 60#) 'GPS.Lat is dividied with 100 and the value of DT(3) before the dot is dividied with 60 and the added to GPS.Lat
    GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ".") + -2)) / 60#) 'GPS.Lon is dividied with 100 and the value of DT(5) before the dot is dividied with 60 and the added to GPS.Lon
End If
Hope this will help you.
__________________
My CC Blog | My Website |Periodic table | Pm me | Ask me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-03-2009, 06:41 AM
Newbie
 
Join Date: Jun 2009
Posts: 8
camolas is an unknown quantity at this point
Re: New in vb need help in array

Hi,

Thanks for the help i will see if i can get it to work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-04-2009, 12:53 PM
Newbie
 
Join Date: Jun 2009
Posts: 8
camolas is an unknown quantity at this point
Re: New in vb need help in array

Code:
 
'Reads GPS
Public Sub ReadGPSInfo(ByVal sData As String, Optional CommaSys As Boolean = True)
Static Ltry As Double   'Last Time we tried to reconnect GPS
Static Buff As String   'Buffer of Data
Dim Nb As Long          'Number of Bytes
Dim b() As Byte         'Array of Bytes
Dim DT() As String      'GPS Fields
Dim latitude() As String
On Error Resume Next

    'If nothing to do
    If sData = "" Then
        Exit Sub
    Else

                       'Process Line of Data
            If Left(sData, 1) = "$" Then
                DT = Split(sData, ",")
        
                Select Case DT(0)
                    Case "$GPRMC"
                        'Get Lat, Long, Speed and Heading
                        GPS.Lat = CDbl(Left(DT(3), InStr(1, DT(3), ".") - 1))
                        GPS.Lat = GPS.Lat & CDbl(Right(DT(3), InStr(1, DT(3), ".") - 1))
                   latitude = GPS.Lat '  data is 41097405 in latitude string
Hi,
I have put the data as i wanted 41097405 , now please can some one explain to me how a split the data into to 41'09.7405 from latitude string?

Please help.
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-07-2009, 06:39 PM
Vswe's Avatar
Code Slinger
 
Join Date: Apr 2009
Location: Uppsala, Sweden
Age: 16
Posts: 8,536
Vswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond repute
Send a message via MSN to Vswe Send a message via Skype™ to Vswe
Re: New in vb need help in array

Do you always have 8 digits?
__________________
My CC Blog | My Website |Periodic table | Pm me | Ask me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-10-2009, 10:01 AM
Newbie
 
Join Date: Jun 2009
Posts: 8
camolas is an unknown quantity at this point
Re: New in vb need help in array

hi,
yes i think sow.
Can you please help?
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 07-10-2009, 10:38 AM
Vswe's Avatar
Code Slinger
 
Join Date: Apr 2009
Location: Uppsala, Sweden
Age: 16
Posts: 8,536
Vswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond reputeVswe has a reputation beyond repute
Send a message via MSN to Vswe Send a message via Skype™ to Vswe
Re: New in vb need help in array

Code:
Dim Before as string
Dim After as string

Before = 41097405
After = Mid(Before,0,2) & "'" & Mid(Before,2,2) & "." & Mid(Before,4,4)
I can't test if it work, but that would probably work.
__________________
My CC Blog | My Website |Periodic table | Pm me | Ask me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Arrays chili5 PHP Tutorials 7 05-22-2009 05:16 PM
Array Sorting Algorithms II whitey6993 C Tutorials 4 12-30-2008 01:26 PM
2D Python Array - "List Indices Must Be Integers" (cannot access an array element) Bertsche Python 3 07-07-2008 11:51 AM
Python 2D array question annannienann Python 3 04-23-2007 05:36 PM


All times are GMT -5. The time now is 09:44 AM.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0