C to VB.Net Conversion Issue

Posted on 2013-06-19
Last Modified: 2013-06-19
Working on a program, I have code that is in C that I need in my program.  I used a converter but having issues..

The problem is this line:

C Code:
  public MainForm()

            Gps = new GpsHandler { TimeOut = 5 }; //Initialize GPS handler
            Gps.NewGpsFix += GpsEventHandler; //Hook up GPS data events to a handler
            FrmGpsSettings = new FrmGpsSettings();
        public static GpsHandler Gps;

Open in new window

It converts into this for VB.Net

Public Sub New()

	Gps = New GpsHandler() With { _
		Key .TimeOut = 5 _
	'Initialize GPS handler
	Gps.NewGpsFix += GpsEventHandler
	'Hook up GPS data events to a handler
	FrmGpsSettings = New FrmGpsSettings()
End Sub
Public Shared Gps As GpsHandler

Open in new window

The error is here:

Gps.NewGpsFix += GpsEventHandler
Argument not specified for parameter 'e' of 'Private Sub GpsEventHandler(sender As Object, e As Ares.SharperGps.GpsHandler.GpsEventArgs)'.

Here is the GpsHandler code.. I do get an error as well on the 'BeginInvoke' line (Expression does not produce a value error).

I can upload the whole source code if needed.

Private Sub GpsEventHandler(sender As Object, e As GpsHandler.GpsEventArgs)

        If InvokeRequired Then
            ' Execute the same method, but this time on the GUI thread
            BeginInvoke(New ThreadStart(Function() GpsEventHandler(sender, e)))
        End If
        tbRawLog.Text += e.Sentence + vbCr & vbLf
        If tbRawLog.Text.Length > 20 * 1024 * 1024 Then
            '20Kb maximum - prevents crash
            tbRawLog.Text = tbRawLog.Text.Substring(10 * 1024 * 1024)
        End If
        'Scroll to bottom
        Select Case e.TypeOfEvent
            Case GpsEventType.GPRMC
                'Recommended minimum specific GPS/Transit data
                If Gps.HasGpsFix Then
                    'Is a GPS fix available?
                    'lbRMCPosition.Text = GPS.GPRMC.Position.ToString("#.000000");
                    lbRMCPosition.Text = Gps.GPRMC.Position.ToString("DMS")
                    lbRMCCourse.Text = Gps.GPRMC.Course.ToString()
                    lbRMCSpeed.Text = Gps.GPRMC.Speed + " mph"
                    lbRMCTimeOfFix.Text = Gps.GPRMC.TimeOfFix.ToString("F")
                    lbRMCMagneticVariation.Text = Gps.GPRMC.MagneticVariation.ToString()
                    StatusBar1.Text = "No fix"
                    lbRMCCourse.Text = "N/A"
                    lbRMCSpeed.Text = "N/A"
                    lbRMCTimeOfFix.Text = Gps.GPRMC.TimeOfFix.ToString()
                End If
                Exit Select
            Case GpsEventType.GPGGA
                'Global Positioning System Fix Data
                If Gps.GPGGA.Position IsNot Nothing Then
                    lbGGAPosition.Text = Gps.GPGGA.Position.ToString("DM")
                    lbGGAPosition.Text = ""
                End If
                lbGGATimeOfFix.Text = Gps.GPGGA.TimeOfFix.Hour + ":" + Gps.GPGGA.TimeOfFix.Minute + ":" + Gps.GPGGA.TimeOfFix.Second
                lbGGAFixQuality.Text = Gps.GPGGA.FixQuality.ToString()
                lbGGANoOfSats.Text = Gps.GPGGA.NoOfSats.ToString()
                lbGGAAltitude.Text = Gps.GPGGA.Altitude & " " & Gps.GPGGA.AltitudeUnits
                lbGGAHDOP.Text = Gps.GPGGA.Dilution.ToString()
                lbGGAGeoidHeight.Text = Gps.GPGGA.HeightOfGeoid.ToString()
                lbGGADGPSupdate.Text = Gps.GPGGA.DGPSUpdate.ToString()
                lbGGADGPSID.Text = Gps.GPGGA.DGPSStationID
                Exit Select
            Case GpsEventType.GPGLL
                'Geographic position, Latitude and Longitude
                lbGLLPosition.Text = Gps.GPGLL.Position.ToString()
                lbGLLTimeOfSolution.Text = (If(Gps.GPGLL.TimeOfSolution.HasValue, Gps.GPGLL.TimeOfSolution.Value.Hours + ":" + Gps.GPGLL.TimeOfSolution.Value.Minutes.ToString() + ":" + Gps.GPGLL.TimeOfSolution.Value.Seconds.ToString(), ""))
                lbGLLDataValid.Text = Gps.GPGLL.DataValid.ToString()
                Exit Select
            Case GpsEventType.GPGSA
                'GPS DOP and active satellites
                If Gps.GPGSA.Mode = "A"c Then
                    lbGSAMode.Text = "Auto"
                ElseIf Gps.GPGSA.Mode = "M"c Then
                    lbGSAMode.Text = "Manual"
                    lbGSAMode.Text = ""
                End If
                lbGSAFixMode.Text = Gps.GPGSA.FixMode.ToString()
                lbGSAPRNs.Text = ""
                If Gps.GPGSA.PRNInSolution.Count > 0 Then
                    For Each prn As String In Gps.GPGSA.PRNInSolution
                        lbGSAPRNs.Text += prn + " "
                    lbGSAPRNs.Text += "none"
                End If
                lbGSAPDOP.Text = Gps.GPGSA.PDOP + " (" + DOPtoWord(Gps.GPGSA.PDOP) + ")"
                lbGSAHDOP.Text = Gps.GPGSA.HDOP + " (" + DOPtoWord(Gps.GPGSA.HDOP) + ")"
                lbGSAVDOP.Text = Gps.GPGSA.VDOP + " (" + DOPtoWord(Gps.GPGSA.VDOP) + ")"
                Exit Select
            Case GpsEventType.GPGSV
                'Satellites in view
                If NMEAtabs.Text = "GPGSV" Then
                    'If NMEAtabs.TabPages(NMEAtabs.SelectedIndex).Text = "GPGSV" Then
                    'Only update this tab when it is active
                End If
                Exit Select
            Case GpsEventType.PGRME
                'Garmin proprietary sentences.
                'lbRMEHorError.Text = Gps.PGRME.EstHorisontalError.ToString()
                'lbRMEVerError.Text = Gps.PGRME.EstVerticalError.ToString()
                'lbRMESphericalError.Text = Gps.PGRME.EstSphericalError.ToString()
                Exit Select
            Case GpsEventType.TimeOut
                'Serialport timeout.
                StatusBar1.Text = "Serialport timeout"
                Exit Select
        End Select

    End Sub

Open in new window

Question by:K-9
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 42

Accepted Solution

sedgwick earned 500 total points
ID: 39259405
Public Sub New()

	Gps = New GpsHandler() With { _
		Key .TimeOut = 5 _
	'Initialize GPS handler
	 AddHandler Gps.NewGpsFix, AddressOf GpsEventHandler 

	'Hook up GPS data events to a handler
	FrmGpsSettings = New FrmGpsSettings()
End Sub
Public Shared Gps As GpsHandler

Open in new window


Author Comment

ID: 39259528
Thank you for the quick response!  That cleared that error, what about this one?

BeginInvoke(New ThreadStart(Function() GpsEventHandler(sender, e)))
Expression does not produce a value.

I will be reading up on this, still an amateur with

Author Comment

ID: 39259543
Nevermind, got it!!

BeginInvoke(New ThreadStart(Sub() GpsEventHandler(sender, e)))


Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question