Exporting Listbox to excel

Hi,

I have read mr. dakin’s book about excel in xojo. I am trying to modified some data, because the samples is generate data randomly.

[code]Dim excel as new ExcelApplication
excel.Visible = true
excel.Workbooks.Add
Dim i as integer
Dim s as string
Dim r as ExcelRange
Dim StartTime as Double = Microseconds

'//Create Data
'For i = 1 to 16000
's = s + “A” + cstr(i) + “B” + EndOfLine.Windows
'Next

//Create Data
For i = 0 to Listbox1.ListCount-1
s = Listbox1.cell(i,0)
Next

//Copy to clipboard
Dim c as new Clipboard
c.SetText(s)
c.Close

//Paste from Clipboard to Excel
r = excel.Range(“A1:A16000”)
r.Select_
excel.ActiveSheet.PasteSpecial(“Text”,false,false)
//MsgBox “16,000 datapoints added to excel”
Dim ThisTime as Double = Microseconds
MsgBox CStr((ThisTime-StartTime)/1000000) + " Seconds"
//Show elapsed time[/code]

I love the way its exporting the data, very fast. so I want to do it using clipboard method. I dont know why, its not running an no error showing.

any help ?

thanks
Regards,
Arief

for starters… “s” contains only the value in your last row of the listbox, so if that one is “empty” you get nothing

As Dave wrote.

You are replacing the content of s in each iteration. Try:

[quote=397046:@Arief Sarjono] For i = 0 to Listbox1.ListCount-1
s = s + EndOfLine + Listbox1.cell(i,0)
Next
[/quote]