Number format

Discussion in 'Questions (Windows Mobile)' started by joeyschlatter, Oct 30, 2007.

  1. joeyschlatter

    joeyschlatter New Member Licensed User

    I have a Listbox that is displaying the GPS altitude but i would like to limit the number of decimal places to 2. i was looking through help topics but it was not very clear to me, being a new user.

    current code:
    Sub GPS_GPSDecoded
    ListBox1.Clear
    ListBox1.add(GPS.status)
    ListBox2.Clear
    ListBox2.Add(GPS.NumberOfSatellites)
    ListBox3.Clear
    ListBox3.add(GPS.SpeedOverGround)
    ListBox4.Clear
    ListBox4.Add(GPS.CourseOverGround)
    ListBox5.Clear
    ListBox5.Add(GPS.Altitude * 3.28084)
    End Sub

    Any help would be great,

    (just got this software this morning and so far i love it)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should use the Format keyword:
    Code:
    ListBox5.Add(Format(GPS.Altitude * 3.28084,"n2"))
    GPS.Altitude is parsed from the GPS string.
    You should check if it is not an empty string (there is no altitude value):
    Code:
    If GPS.Altitude <> "" Then
      ListBox5.Add(Format(
    GPS.Altitude * 3.28084,"n2"))
    End If
    BTW, why don't you use a TextBox or a Label instead of the ListBoxes?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice