My application uses a multi-line text box in which I feed a row of numbers from a comma-delimited text file like in the following code:
The rows of numbers may look like this in the text file:
1, 1205.678, 2345.123, iron_rod
12, 3456.789, 9876.234, None
4, 1234.567, 2145.587, None
The comma is replaced with a space in the display text box
The first number is not always consecutive to the one before it. However, when I display it to the user, I would like to have the rows sorted on the first number.
I saw a "Sort" function in the "Constants" in the docs but don't know how to incorporate it if that is even possible. I could also use a list box if that would make it easier to sort. Thanks for any advice.
Jim Schuchert
B4X:
Sub btnListOK_Click
Select txtlistDec.Text
Case 0
sdecpl="N0"
Case 1
sdecpl="N1"
Case 2
sdecpl="N2"
Case 3
sdecpl="N3"
Case 4
sdecpl="N4"
Case 5
sdecpl="N5"
End Select
FileClose(c)
FileOpen(c,strfilename,cRead)
nextline:
lineoftext=FileRead(c)
If lineoftext="" Then Goto listend
coord()=StrSplit(lineoftext,",")
txtlistdisplay.Text =txtlistdisplay.text & coord(0) & " " & Format(coord(1),sdecpl) & " " & _
Format(coord(2),sdecpl) & " " & coord(3) & CRLF
Goto nextline
FileClose(c)
listend:
End Sub
The rows of numbers may look like this in the text file:
1, 1205.678, 2345.123, iron_rod
12, 3456.789, 9876.234, None
4, 1234.567, 2145.587, None
The comma is replaced with a space in the display text box
The first number is not always consecutive to the one before it. However, when I display it to the user, I would like to have the rows sorted on the first number.
I saw a "Sort" function in the "Constants" in the docs but don't know how to incorporate it if that is even possible. I could also use a list box if that would make it easier to sort. Thanks for any advice.
Jim Schuchert