Loading csv into a button

Hi,
I want to load a csv file into button caption.
Is there any others simple ways to do it than this code,

IF TabPanel2.value=0 then
  if BevelButton18.Caption <>"Item" then
    l_page.Text=str(val(l_page.text)+1)
  end if
  
  Select case l_page.text
    
  case "1"
    
    BevelButton1.Caption=lstPrice.cell(0,1)
    BevelButton2.Caption=lstPrice.cell(1,1)
    BevelButton3.Caption=lstPrice.cell(2,1)
    BevelButton4.Caption=lstPrice.cell(3,1)
    BevelButton5.Caption=lstPrice.cell(4,1)
    BevelButton6.Caption=lstPrice.cell(5,1)
    BevelButton7.Caption=lstPrice.cell(6,1)
    BevelButton8.Caption=lstPrice.cell(7,1)
    BevelButton9.Caption=lstPrice.cell(8,1)
    BevelButton10.Caption=lstPrice.cell(9,1)
    BevelButton11.Caption=lstPrice.cell(10,1)
    BevelButton12.Caption=lstPrice.cell(11,1)
    BevelButton13.Caption=lstPrice.cell(12,1)
    BevelButton14.Caption=lstPrice.cell(13,1)
    BevelButton15.Caption=lstPrice.cell(14,1)
    BevelButton16.Caption=lstPrice.cell(15,1)
    BevelButton17.Caption=lstPrice.cell(16,1)
    BevelButton18.Caption=lstPrice.cell(17,1)
    
  case "2"
    
    BevelButton1.Caption=lstPrice.cell(18,1)
    BevelButton2.Caption=lstPrice.cell(19,1)
    BevelButton3.Caption=lstPrice.cell(20,1)
    BevelButton4.Caption=lstPrice.cell(21,1)
    BevelButton5.Caption=lstPrice.cell(22,1)
    BevelButton6.Caption=lstPrice.cell(23,1)
    BevelButton7.Caption=lstPrice.cell(24,1)
    BevelButton8.Caption=lstPrice.cell(25,1)
    BevelButton9.Caption=lstPrice.cell(26,1)
    BevelButton10.Caption=lstPrice.cell(27,1)
    BevelButton11.Caption=lstPrice.cell(28,1)
    BevelButton12.Caption=lstPrice.cell(29,1)
    BevelButton13.Caption=lstPrice.cell(30,1)
    BevelButton14.Caption=lstPrice.cell(31,1)
    BevelButton15.Caption=lstPrice.cell(32,1)
    BevelButton16.Caption=lstPrice.cell(33,1)
    BevelButton17.Caption=lstPrice.cell(34,1)
    BevelButton18.Caption=lstPrice.cell(35,1)
    
  case "3"
    BevelButton1.Caption=lstPrice.cell(36,1)
    BevelButton2.Caption=lstPrice.cell(37,1)
    BevelButton3.Caption=lstPrice.cell(38,1)
    BevelButton4.Caption=lstPrice.cell(39,1)
    BevelButton5.Caption=lstPrice.cell(40,1)
    BevelButton6.Caption=lstPrice.cell(41,1)
    BevelButton7.Caption=lstPrice.cell(42,1)
    BevelButton8.Caption=lstPrice.cell(43,1)
    BevelButton9.Caption=lstPrice.cell(44,1)
    BevelButton10.Caption=lstPrice.cell(45,1)
    BevelButton11.Caption=lstPrice.cell(46,1)
    BevelButton12.Caption=lstPrice.cell(47,1)
    BevelButton13.Caption=lstPrice.cell(48,1)
    BevelButton14.Caption=lstPrice.cell(49,1)
    BevelButton15.Caption=lstPrice.cell(50,1)
    BevelButton16.Caption=lstPrice.cell(51,1)
    BevelButton17.Caption=lstPrice.cell(52,1)
    BevelButton18.Caption=lstPrice.cell(53,1)
    
  case "4"
    
    BevelButton1.Caption=lstPrice.cell(54,1)
    BevelButton2.Caption=lstPrice.cell(55,1)
    BevelButton3.Caption=lstPrice.cell(56,1)
    BevelButton4.Caption=lstPrice.cell(57,1)
    BevelButton5.Caption=lstPrice.cell(58,1)
    BevelButton6.Caption=lstPrice.cell(59,1)
    BevelButton7.Caption=lstPrice.cell(60,1)
    BevelButton8.Caption=lstPrice.cell(61,1)
    BevelButton9.Caption=lstPrice.cell(62,1)
    BevelButton10.Caption=lstPrice.cell(63,1)
    BevelButton11.Caption=lstPrice.cell(64,1)
    BevelButton12.Caption=lstPrice.cell(65,1)
    BevelButton13.Caption=lstPrice.cell(66,1)
    BevelButton14.Caption=lstPrice.cell(67,1)
    BevelButton15.Caption=lstPrice.cell(68,1)
    BevelButton16.Caption=lstPrice.cell(69,1)
    BevelButton17.Caption=lstPrice.cell(70,1)
    BevelButton18.Caption=lstPrice.cell(71,1)
    
  case "5"
    BevelButton1.Caption=lstPrice.cell(72,1)
    BevelButton2.Caption=lstPrice.cell(73,1)
    BevelButton3.Caption=lstPrice.cell(74,1)
    BevelButton4.Caption=lstPrice.cell(75,1)
    BevelButton5.Caption=lstPrice.cell(76,1)
    BevelButton6.Caption=lstPrice.cell(77,1)
    BevelButton7.Caption=lstPrice.cell(78,1)
    BevelButton8.Caption=lstPrice.cell(79,1)
    BevelButton9.Caption=lstPrice.cell(80,1)
    BevelButton10.Caption=lstPrice.cell(81,1)
    BevelButton11.Caption=lstPrice.cell(82,1)
    BevelButton12.Caption=lstPrice.cell(83,1)
    BevelButton13.Caption=lstPrice.cell(84,1)
    BevelButton14.Caption=lstPrice.cell(85,1)
    BevelButton15.Caption=lstPrice.cell(86,1)
    BevelButton16.Caption=lstPrice.cell(87,1)
    BevelButton17.Caption=lstPrice.cell(88,1)
    BevelButton18.Caption=lstPrice.cell(89,1)
    
  case "6"
    BevelButton1.Caption=lstPrice.cell(90,1)
    BevelButton2.Caption=lstPrice.cell(91,1)
    BevelButton3.Caption=lstPrice.cell(92,1)
    BevelButton4.Caption=lstPrice.cell(93,1)
    BevelButton5.Caption=lstPrice.cell(94,1)
    BevelButton6.Caption=lstPrice.cell(95,1)
    BevelButton7.Caption=lstPrice.cell(96,1)
    BevelButton8.Caption=lstPrice.cell(97,1)
    BevelButton9.Caption=lstPrice.cell(98,1)
    BevelButton10.Caption=lstPrice.cell(99,1)
    BevelButton11.Caption=lstPrice.cell(100,1)
    BevelButton12.Caption=lstPrice.cell(101,1)
    BevelButton13.Caption=lstPrice.cell(102,1)
    BevelButton14.Caption=lstPrice.cell(103,1)
    BevelButton15.Caption=lstPrice.cell(104,1)
    BevelButton16.Caption=lstPrice.cell(105,1)
    BevelButton17.Caption=lstPrice.cell(106,1)
    BevelButton18.Caption=lstPrice.cell(107,1)
    
  case "7"
    BevelButton1.Caption=lstPrice.cell(108,1)
    BevelButton2.Caption=lstPrice.cell(109,1)
    BevelButton3.Caption=lstPrice.cell(110,1)
    BevelButton4.Caption=lstPrice.cell(111,1)
    BevelButton5.Caption=lstPrice.cell(112,1)
    BevelButton6.Caption=lstPrice.cell(113,1)
    BevelButton7.Caption=lstPrice.cell(114,1)
    BevelButton8.Caption=lstPrice.cell(115,1)
    BevelButton9.Caption=lstPrice.cell(116,1)
    BevelButton10.Caption=lstPrice.cell(117,1)
    BevelButton11.Caption=lstPrice.cell(118,1)
    BevelButton12.Caption=lstPrice.cell(119,1)
    BevelButton13.Caption=lstPrice.cell(120,1)
    BevelButton14.Caption=lstPrice.cell(121,1)
    BevelButton15.Caption=lstPrice.cell(122,1)
    BevelButton16.Caption=lstPrice.cell(123,1)
    BevelButton17.Caption=lstPrice.cell(124,1)
    BevelButton18.Caption=lstPrice.cell(125,1)
    
  case "8"
    BevelButton1.Caption=lstPrice.cell(126,1)
    BevelButton2.Caption=lstPrice.cell(127,1)
    BevelButton3.Caption=lstPrice.cell(128,1)
    BevelButton4.Caption=lstPrice.cell(129,1)
    BevelButton5.Caption=lstPrice.cell(130,1)
    BevelButton6.Caption=lstPrice.cell(131,1)
    BevelButton7.Caption=lstPrice.cell(132,1)
    BevelButton8.Caption=lstPrice.cell(133,1)
    BevelButton9.Caption=lstPrice.cell(134,1)
    BevelButton10.Caption=lstPrice.cell(134,1)
    BevelButton11.Caption=lstPrice.cell(136,1)
    BevelButton12.Caption=lstPrice.cell(137,1)
    BevelButton13.Caption=lstPrice.cell(138,1)
    BevelButton14.Caption=lstPrice.cell(139,1)
    BevelButton15.Caption=lstPrice.cell(140,1)
    BevelButton16.Caption=lstPrice.cell(141,1)
    BevelButton17.Caption=lstPrice.cell(142,1)
    BevelButton18.Caption=lstPrice.cell(143,1)
  end Select
end if

its still has a problem sometimes, its depend to the csv list.

thanks
arief

I think the other Tim said it best in this very recent CSV parsing thread:

Hi,
Thanks for the info. I have downloaded , but seems not working properly on xojo 2018r4, the app is freezing.

actually I just need to put the caption on every button. it doesnt meant has to be done by csv, database also would be fine.
Will it possible to do with sql database ?

thanks
regards,
arief

Yes it is.

But, always think simple.

In your message, all I see is data extracted from a ListBox and set into all purposes BevelButtons…

Example:

BevelButton1.Caption=lstPrice.cell(0,1)

Using BB_Microphone.Caption = NthField(Price_List_TIS.ReadLine, Chr(9), 2)

Where that line is:
Microphone AKG 1256 \tab $558.99 // Your designation / price instead…

will simplify your life and debug…

Remember: I do not know what your software do, so this advice may not be as relevant as intended; you understand what I mean.

Also:
you have 8 times the same code where one is enough if you set a multiplicator into the Row value:

BevelButton1.Caption=lstPrice.cell(0*Val(l_page.text),1)

Code above to be adapted: Val(l_page.text) is the multiplicator and have to be set a line before / Checked to not be > 8.

IMHO.

Hi,

yes, this code is way easier,

BevelButton1.Caption=lstPrice.cell(0*Val(l_page.text),1)

But I dont know how to implement it .

I want to create a menu using bevelbutton based from a csv list.
3 columns
code,name,price.
every page is 18 buttons.

to handle the listbox text into the bevelbutton is done. but how to put the code in that bevelbutton.
when the button is pressed, it will read the code(column 0)

Select case l_page.text
  
case "1"
  t_kode.text = lstPrice.cell(0,0)
case "2"
  t_kode.text = lstPrice.cell(18,0)
case "3"
  t_kode.text = lstPrice.cell(36,0)
case "4"
  t_kode.text = lstPrice.cell(54,0)
case "5"
  t_kode.text = lstPrice.cell(72,0)
case "6"
  t_kode.text = lstPrice.cell(90,0)
case "7"
  t_kode.text = lstPrice.cell(108,0)
case "8"
  t_kode.text = lstPrice.cell(126,0)
end Select

what I did so far is just to read and mapped the row into the bevelbutton by using listbox.listindex.

thanks
regards,
arief

you could subclass your button for own propertys and methods.
i would also create a article class with this propertys code,name,price.

You have 8 pages and 18 buttons per page ?

Add a Property (PgNbr) and set it to the page number,

then, each line BevelButton line will look like:

BevelButton1.Caption=lstPrice.cell(0*PgNbr,1)

Of course, the PgNbr Property is changed at each page change, so it will work.

But: it is difficult to guess advice with so few information.

What is lacking (for example) is a window screen shot.

Also, your source text can be loaded (Window1.Open) in lstPrice(143) and you access the data from that array (instead of from the ListBox).

Just ideas…