I'm using VB6 and I have a folder where I have n
number of files.
I want to change the file extension to .txt
. I used the code below to change the extension of all .fin
files to .txt
.
Dim filename1 As String
filename1 = Dir$(txtsourcedatabasefile & "\*.fin", vbDirectory)
Do While filename1 <> ""
Dim strInput As String
Dim strOutput As String
Dim strChar As String
Dim intChar As Integer
Dim intLoop As Integer
strInput = filename1
strOutput = ""
For intLoop = 1 To Len(strInput)
strChar = Mid$(strInput, intLoop, 1)
intChar = Asc(strChar)
If ((intChar >= 48) And (intChar <= 57)) Or _
((intChar >= 65) And (intChar <= 90)) Or _
((intChar >= 97) And (intChar <= 122)) Or _
(intChar = 95) Then
strOutput = strOutput & strChar
End If
Next
Name txtsourcedatabasefile & "\" & filename1 As txtsourcedatabasefile & "\" & strOutput & ".txt"
filename1 = Dir$
Loop
The code above is working for changing .fin
to .txt
, but with filenames without any extension, like Clockings2.mis04062009 022511 PM
, Silver_421_export
, etc., aren't transformed to a .txt
extention. For example, Clockings2mis04062009022511PM.txt
, Silver_421_export.txt
.
How should I change this code?