Hi,
I have some data, held on the hard-drive in a .csv file. At start-up I read this in to an array and when the user hits a command button I want to show the data in a grid or tabulated screen that the user can scroll up and down and select one item at a time.
I've poked around with this for a day or two and come up with the code below.
code start------------------------------------
myTab = vbTab & " "
lstDisplay.Visible = True
For n = 1 To 100
'name
xfer2 = Trim(myData(n, 1)) & " "
xfer2 = Left(xfer2, 18)
xfer1 = xfer2 & myTab
'price
xfer2 = Trim(myData(n, 2)) & " "
xfer2 = Left(xfer2, 12)
xfer1 = xfer1 & xfer2 & myTab
'quantity
xfer2 = Trim(myData(n, 3)) & " "
xfer2 = Left(xfer2, 10)
xfer1 = xfer1 & xfer2 & myTab
'tax
xfer2 = Trim(myData(n, 4)) & " "
xfer2 = Left(xfer2, 10)
xfer1 = xfer1 & xfer2
lstDisplay.AddItem xfer1
Next n
code end------------------------------------
xfer2 gets mydata and adds fifteen spaces (I tried various figures here), then gets trimmed to a suitable length and added to xfer1. When I've got all the data for one line I add it to the listbox.
It sort of works, bearing in mind my slightly dodgy code (I learnt on QuickBasic 30 years ago!)
From time to time, if the 'name' is quite long to start with, it throws the rest of the columns out but only on that line. The next line shows as normal. But why doesn't it get limited when I trim it to length?
Is there something that I'm missing, or can anyone suggest a better way of displaying upto maybe 400 lines, of up to nine columns, and still allow the user to click to select one item?
Regards
Peter
I have some data, held on the hard-drive in a .csv file. At start-up I read this in to an array and when the user hits a command button I want to show the data in a grid or tabulated screen that the user can scroll up and down and select one item at a time.
I've poked around with this for a day or two and come up with the code below.
code start------------------------------------
myTab = vbTab & " "
lstDisplay.Visible = True
For n = 1 To 100
'name
xfer2 = Trim(myData(n, 1)) & " "
xfer2 = Left(xfer2, 18)
xfer1 = xfer2 & myTab
'price
xfer2 = Trim(myData(n, 2)) & " "
xfer2 = Left(xfer2, 12)
xfer1 = xfer1 & xfer2 & myTab
'quantity
xfer2 = Trim(myData(n, 3)) & " "
xfer2 = Left(xfer2, 10)
xfer1 = xfer1 & xfer2 & myTab
'tax
xfer2 = Trim(myData(n, 4)) & " "
xfer2 = Left(xfer2, 10)
xfer1 = xfer1 & xfer2
lstDisplay.AddItem xfer1
Next n
code end------------------------------------
xfer2 gets mydata and adds fifteen spaces (I tried various figures here), then gets trimmed to a suitable length and added to xfer1. When I've got all the data for one line I add it to the listbox.
It sort of works, bearing in mind my slightly dodgy code (I learnt on QuickBasic 30 years ago!)
From time to time, if the 'name' is quite long to start with, it throws the rest of the columns out but only on that line. The next line shows as normal. But why doesn't it get limited when I trim it to length?
Is there something that I'm missing, or can anyone suggest a better way of displaying upto maybe 400 lines, of up to nine columns, and still allow the user to click to select one item?
Regards
Peter