Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to list all .txt files in a directory, inside combo box

Status
Not open for further replies.

mark01

Technical User
Jan 17, 2001
600
0
0
US
I have a directory that contains at least 25 .txt files. It also contains other files. How can i list just the .txt files inside the combo box?
 
Try this.

CommonDialog1.Filter = "Text Files(*.txt)|*.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1

Do While Not EOF(1)
Line Input #1, strTemp
Loop

Close #1

Add strTemp to combo box.

Jeffery Smith (Smitty)
PEC Solutions Inc.
A+ Network+ MCSA MCSE
 
Just use the Dir function:
[tt]
Dim strText As String
strText = Dir("c:\mydir\*.txt")
If Len(strText) > 0 Then
Combo1.AddItem strText
Do
strText = Dir
Debug.Print strText
Combo1.AddItem strText
Loop While Len(strText) > 0
End If
[/tt]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Cool, thanks, it worked Johnwm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top