Fordraiders
asked on
Loading Excel file names to combobox
vb.net 2003
What I need:
To load excel file names to a combo box
Form1
cboFileLoad
Thanks
fordraiders
What I need:
To load excel file names to a combo box
Form1
cboFileLoad
Thanks
fordraiders
ASKER
do I need to add a reference ?
for
Directory.GetFiles("C:\Wha t_ever_Fol der\", "*.xls")' filter only excel files *.xls
Directory.GetFiles <-----does not like this
Thanks for replying
for
Directory.GetFiles("C:\Wha
Directory.GetFiles <-----does not like this
Thanks for replying
Imports System.IO
this should do it
vbturbo
this should do it
vbturbo
ASKER
it says "directory" is not declared..
I put Imports System.IO
in Assembly.info Correct ?
I put Imports System.IO
in Assembly.info Correct ?
ASKER
Sorry but coming from vb6
The same here -)
Imports System.IO
is a name space so you can access all IO operations in that particular class.
is a name space so you can access all IO operations in that particular class.
Here is an example
Imports System
Imports System.IO
Imports System.Data.OleDb
Public Class SomeClass
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ExcelFile As String
Dim FindFiles() As String = Directory.GetFiles("C:\Wha t_ever_Fol der\", "*.xls")' filter only excel files *.xls
For Each ExcelFile In FindFiles
ComboBox1.Items.Add(ExcelF ile )
Next
End Sub
Private Sub btnspecial_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnspecial.Click
Dim infoform As New special
infoform.ShowDialog()
End Sub
End Class
Imports System
Imports System.IO
Imports System.Data.OleDb
Public Class SomeClass
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ExcelFile As String
Dim FindFiles() As String = Directory.GetFiles("C:\Wha
For Each ExcelFile In FindFiles
ComboBox1.Items.Add(ExcelF
Next
End Sub
Private Sub btnspecial_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnspecial.Click
Dim infoform As New special
infoform.ShowDialog()
End Sub
End Class
Or it would be better to say
Imports System.IO
is a namespace so you can access IO operations - in that namespace with all the classes it contains.
Imports System.IO
is a namespace so you can access IO operations - in that namespace with all the classes it contains.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
u can also directly use the VB Turbo Code with
[I have just written the Namespace before the Directory class have a look at it]
[in this case u don't have to import the Namespace]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ExcelFile As String
Dim FindFiles() As String = System.IO.Directory.GetFil
For Each ExcelFile In FindFiles
ComboBox1.Items.Add(ExcelF
Next
End Sub
Try It
sorry i was 3 mins late to post the same comment have a look at the same comment by vbturbo
thumbs up manch -:)
all relevant inputs and second opinions are important to get an as detailed explanation as posible to the asker.
vbturbo
all relevant inputs and second opinions are important to get an as detailed explanation as posible to the asker.
vbturbo
ASKER
manch, vbturbo..
Worked fine now!
Except I do not need to see the dir path in the combo box.
I need the code to tell me where its at but I do not need to see the dir path in the box.
Thanjks
Worked fine now!
Except I do not need to see the dir path in the combo box.
I need the code to tell me where its at but I do not need to see the dir path in the box.
Thanjks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all very very great stuff...
' to add item to combo
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ExcelFile As String
Dim FindFiles() As String = Directory.GetFiles("C:\Wha
For Each ExcelFile In FindFiles
ComboBox1.Items.Add(ExcelF
Next
End Sub
vbturbo