Hello EveryBody
i want to change a file extention property in visual basic 6
Example;
i have a File test.txt or test.jpg what we want ?
and we use a command botton and two textbox
Text1.text = "C:\test.txt" 'Textbox 1 is my file path
Text2.text = ".pdf" or ".psd" ' textbox 2 is my extention field beacause any time we want to change extention. psd,pdf,tmp,jpg Etc
change Textbox1 file path file extention in textbox2 Extention

When i use orignal extention then my file work.

See if this helps :

Public Function ChangeFileExt(ByVal aFilename As String, ByVal NewExt As String) As Boolean
Dim p As Long
Dim bp As Long
Dim nFileName As String

On Error Resume Next
ChangeFileExt = False
If aFilename = "" Then Exit Function
p = 0
Do
    bp = p
    p = InStr(p + 1, aFilename, ".", vbBinaryCompare)
Loop Until p = 0

If bp > 0 Then
    nFileName = Left(aFilename, bp - 1)
Else
    nFileName = aFilename
End If

nFileName = nFileName & "." & NewExt

Err.Clear

Name aFilename As nFileName

If Err.Number = 0 Then ChangeFileExt = True

End Function

' Change file type
Private Sub Command1_Click()
Call ChangeFileExt("D:\test.txt", "jx") ' from .txt become .jx
End Sub

Your case :

Text1.Text = "D:\test.txt"
Text2.Text = "jx"
Private Sub Command1_Click()
Call ChangeFileExt(Text1.Text, Text2.Text) 
End Sub

Thanks Brother its work i am very thanks full to you
you are a genius
Thanks thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.