Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
With OpenFileDialog1
.ShowReadOnly = False
.Filter = "All Files|*.*|Excel Files (*)|*;*.xls;*.xlsx"
.FilterIndex = 2
If .ShowDialog = DialogResult.OK Then
APP1 = New Excel.Application
workbook1 = APP1.Workbooks.Open(.FileName)
worksheet1 = workbook1.Worksheets("sheet1")
End If
End With
Dim r As Single
Dim l As Object
For r = 1 To 10
l = worksheet1.Cells(r, 1).Value
ListBox1.Items.Add(l)
Next
ListBox3.Items.Clear()
ListBox3.Items.AddRange(ListBox1.Items.Cast(Of String).Except(ListBox2.Items.Cast(Of String)).ToArray)
End Sub
My simple For loop is what generates the data, and need that to just pull in everything in column A that has data (can't blindly extend the number 'cause errors arise).
Was looking into a Boolean loop so changed that part to read:
Dim r, n As Single
Dim l As Object
Dim non_empty As Boolean = True
Do While non_empty = True
For r = 1 To n
l = worksheet1.Cells(r, 1).Value
If worksheet1.Cells(r, 1).value <> "" Then
ListBox1.Items.Add(l)
n = r + 1
Else
non_empty = False
End If
Next
Loop
however this loop doesn't end... thoughts/comments?

New Topic/Question
Reply



MultiQuote


|