loading text file into listbox with a filter (solved)
Posted: Thursday 24th February 2022 12:34pm
Haya,
working with Gambas 3.16.2 and as a beginner, I'm getting around quite good. However in a couple of cases my logic cat does not comply ...
I have a simple txt file and load it into a ListBox.
__________________________________________________________
Dialog.Filter = ["*.txt", "Text Files", "*", "All Files"]
If Dialog.OpenFile() Then Return
ListBox1.List = Split(File.Load(Dialog.Path), "\n")
__________________________________________________________
So far, so good.
Now I want to remove the first 12 lines/items and even as it seems simple to do I'm running into sytax errors.
__________________________________________________________
Listbox1.Remove(ListBox1[0...11] ???
__________________________________________________________
Sorry, not getting it right.
Further, the text file comes in approx. 250 lines as follows:
16
10
27
13
-- -- --
14
16
26
28
25
0
(sorry on submitting the post the mentiond spaces do not show - so, before each number there are 3 spaces or two spaces and also after the numbers ...)
No I want to remove with a FOR loop - or on loading the file - all spaces, empty lines and the awkward dashes inbetween (-- -- --)
Another approach would be to list only the numbers, only one number as one item/line.
Sipping throu a lot of documentation did not help me to write the right syntax...
Would really appreciate some few lines in order to get things going.
Thanks and regards.
Klaus
working with Gambas 3.16.2 and as a beginner, I'm getting around quite good. However in a couple of cases my logic cat does not comply ...
I have a simple txt file and load it into a ListBox.
__________________________________________________________
Dialog.Filter = ["*.txt", "Text Files", "*", "All Files"]
If Dialog.OpenFile() Then Return
ListBox1.List = Split(File.Load(Dialog.Path), "\n")
__________________________________________________________
So far, so good.
Now I want to remove the first 12 lines/items and even as it seems simple to do I'm running into sytax errors.
__________________________________________________________
Listbox1.Remove(ListBox1[0...11] ???
__________________________________________________________
Sorry, not getting it right.
Further, the text file comes in approx. 250 lines as follows:
16
10
27
13
-- -- --
14
16
26
28
25
0
(sorry on submitting the post the mentiond spaces do not show - so, before each number there are 3 spaces or two spaces and also after the numbers ...)
No I want to remove with a FOR loop - or on loading the file - all spaces, empty lines and the awkward dashes inbetween (-- -- --)
Another approach would be to list only the numbers, only one number as one item/line.
Sipping throu a lot of documentation did not help me to write the right syntax...
Would really appreciate some few lines in order to get things going.
Thanks and regards.
Klaus