Decimal numbers and Devices languages. [modified]
-
Hi all, I written the below code with the purpose to sort several string-arrays and two ComboBox.Items. It's important to precise that I only want to change the order with witch them are stored (in arrays) or displayed in ComboBox.Items (not to sort them alphabetically). It's also important to precise for Lat1 and Lon1, I input them in TextBox3, using the "." (dot) separator. Using ",", return me an error. Well, the following code works perfectly (as I espected from it) in emulator of English VS 2005, but doesn't works perfectly in real device (PPC Windows mobile 2003 SE). I obtain in ComboBoxes. items a not correct and different order of items. I am almost sure that cause of the problem is the different Language of device (Italian) because the logic of the code is correct, but I don't know how to resolve it. Italian language use the comma "," as decimal delimitator, instead of the dot. Can someone help me, please? Thanks Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click Dim Lat1, Lon1, Lat2, Lon2 As Double Distances = New Single(LatsWpt.GetLength(0) - 1) {} Dim Distance As Single Dim Index As Integer Dim NRow As Integer Dim LatString As String = "" Dim LonString As String = "" For Counter = 1 To Len(TextBox3.Text) If Microsoft.VisualBasic.Mid(TextBox3.Text, Counter, 1) <> " " Then LatString = LatString + Microsoft.VisualBasic.Mid(TextBox3.Text, Counter, 1) Else Exit For Next For Counter = Counter + 1 To Len(TextBox3.Text) If Microsoft.VisualBasic.Mid(TextBox3.Text, Counter, 1) <> " " Then LonString = LonString + Microsoft.VisualBasic.Mid(TextBox3.Text, Counter, 1) Next Lat1 = Val(LatString) Lon1 = Val(LonString) For Index = 1 To LatsWpt.GetLength(0) - 1 Lat2 = LatsWpt(Index) Lon2 = LongsWpt(Index) Distance = (6371 * 3.1415926 * Math.Sqrt((Lat2 - Lat1) * (Lat2 - Lat1) + Math.Cos(Lat2 / 57.29578) * Math.Cos(Lat1 / 57.29578) * (Lon2 - Lon1) * (Lon2 - Lon1)) / 180) Distances(Index) = Distance Next For Index = Distances.GetLength(0) - 1 To 1 Step -1 For Counter = 1 To Index If Distances(Counter) > Distances(0) Then Distances(0) = Distances(Counter) : NRow = Counter Next Distances(NRow) = Distances(Index) : Distances(Index) = Distances(0) :