Click here to Skip to main content
15,916,019 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to build a COM or Win32 in .NET IDE Pin
Nicholas Cardi20-Dec-04 7:24
Nicholas Cardi20-Dec-04 7:24 
QuestionExcel Interop with Existing File? Pin
halhamilton20-Dec-04 3:59
halhamilton20-Dec-04 3:59 
AnswerRe: Excel Interop with Existing File? Pin
Jim Matthews20-Dec-04 6:30
Jim Matthews20-Dec-04 6:30 
GeneralRe: Excel Interop with Existing File? Pin
halhamilton22-Dec-04 6:15
halhamilton22-Dec-04 6:15 
Questionhow to treat events async.? Pin
carlos_rocha20-Dec-04 3:17
carlos_rocha20-Dec-04 3:17 
AnswerRe: how to treat events async.? Pin
Nicholas Cardi20-Dec-04 5:24
Nicholas Cardi20-Dec-04 5:24 
GeneralAdd filenames to list box Pin
johnjsm20-Dec-04 2:07
johnjsm20-Dec-04 2:07 
GeneralRe: Add filenames to list box Pin
Nicholas Cardi20-Dec-04 5:54
Nicholas Cardi20-Dec-04 5:54 
Here you go.

1) You need to add a referance to the Microsoft Scripting Runtime.
2) Add a Command Button to the form
3) Add a ListBox to the form
4) Have Fun

'///BEGIN CODE///

Private Sub Command1_Click()

Dim fso As New FileSystemObject
Dim fld As Folder
Dim fi As File
Dim I As Long

Set fld = fso.GetFolder("C:\")

For Each fi In fld.Files
If MatchesExtension("txt", fi.Name) Then
List1.AddItem fi.Name
End If
Next

End Sub

'Takes a filename and a file extension to match
'Works in reverse on the file name looking for the last
'period character. Once found the string is then compared to the
'passed in sFileExtension parameter.
Private Function MatchesExtension(sFileExtension As String, sFileName As String) As Boolean
Dim sChar As String
Dim sTemp As String
Dim I As Long

MatchesExtension = False

For I = Len(sFileName) To 1 Step -1
sChar = Mid(sFileName, I, 1)
If sChar = "." Then
If sTemp = sFileExtension Then
MatchesExtension = True
Else
MatchesExtension = False
End If
Exit For
End If
sTemp = sTemp & sChar
Next I

End Function

'///END CODE///'

Forever Developing
GeneralRe: Add filenames to list box Pin
johnjsm20-Dec-04 22:09
johnjsm20-Dec-04 22:09 
GeneralRe: Add filenames to list box Pin
Nicholas Cardi21-Dec-04 4:14
Nicholas Cardi21-Dec-04 4:14 
GeneralRe: Add filenames to list box Pin
johnjsm21-Dec-04 4:56
johnjsm21-Dec-04 4:56 
GeneralRe: Add filenames to list box Pin
johnjsm22-Dec-04 0:25
johnjsm22-Dec-04 0:25 
GeneralRe: Add filenames to list box Pin
johnjsm22-Dec-04 0:24
johnjsm22-Dec-04 0:24 
GeneralRe: Add filenames to list box Pin
Nicholas Cardi22-Dec-04 5:04
Nicholas Cardi22-Dec-04 5:04 
GeneralRe: Add filenames to list box Pin
johnjsm22-Dec-04 5:35
johnjsm22-Dec-04 5:35 
GeneralRe: Add filenames to list box Pin
Nicholas Cardi22-Dec-04 5:51
Nicholas Cardi22-Dec-04 5:51 
GeneralRe: Add filenames to list box Pin
johnjsm22-Dec-04 6:18
johnjsm22-Dec-04 6:18 
GeneralUsing drag and Drop picture to a label or something else for a scrabble game Im developing Pin
sourcezilla20-Dec-04 0:51
sourcezilla20-Dec-04 0:51 
GeneralRe: Using drag and Drop picture to a label or something else for a scrabble game Im developing Pin
Tom John20-Dec-04 2:28
Tom John20-Dec-04 2:28 
GeneralResizing the Windows Form through code once it has been maximized Pin
Tweetyshwet19-Dec-04 23:12
Tweetyshwet19-Dec-04 23:12 
GeneralRe: Resizing the Windows Form through code once it has been maximized Pin
Tom John20-Dec-04 0:42
Tom John20-Dec-04 0:42 
GeneralRunning Bytes of array from memory Pin
matrixcine19-Dec-04 22:50
matrixcine19-Dec-04 22:50 
GeneralRe: Running Bytes of array from memory Pin
Dave Kreskowiak20-Dec-04 1:12
mveDave Kreskowiak20-Dec-04 1:12 
GeneralRe: Running Bytes of array from memory Pin
Anonymous20-Dec-04 2:17
Anonymous20-Dec-04 2:17 
GeneralRe: Running Bytes of array from memory Pin
Dave Kreskowiak20-Dec-04 3:31
mveDave Kreskowiak20-Dec-04 3:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.