-
Dec 16th, 2015, 05:22 AM
#1
Thread Starter
New Member
[RESOLVED] Adding items to listbox from excel
I have a column in excel file contain 100 row I'm trying to import this column into listbox using a button
The problem is that only 48 row is importing from the excel column .
why not all rows inside the column are imported?
here is my code (vb.net form)
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim oExcel As Object = CreateObject("Excel.Application")
Dim oBook As Object = oExcel.Workbooks.Open("C:\Users\User\Desktop\1.xlsx")
Dim oSheet As Object = oBook.Worksheets(1)
Dim i As Integer
Dim cell As String
For i = 0 To AscW(ListBox1.Items.Count.ToString()(i = i + 1)) - 1
'set cell name, e.g. A1, A2, etc
cell = "B" & Convert.ToString(i + 1)
' get cell data from Excel
cell = oSheet.Range(cell).Value
If cell = "" Then
Exit For
Else
ListBox5.Items.Add(cell)
End If
Next
oExcel.Quit()
End Sub
-
Dec 16th, 2015, 06:31 AM
#2
Re: Adding items to listbox from excel
what is the value of this:
Code:
AscW(ListBox1.Items.Count.ToString()(i = i + 1)) - 1
-
Dec 16th, 2015, 06:36 AM
#3
Re: [RESOLVED] Adding items to listbox from excel
What is the purpose of this code and what are you trying to achieve with it?
Code:
For i = 0 To AscW(ListBox1.Items.Count.ToString()(i = i + 1)) - 1
Maybe it's a typo.
/shrugs
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|