Hello!! Hoping to get some more help here..![]()
The code below can save a profile.
If the same filename exists, and the user chooses not to overwrite the file, I want to add -nn (-01, then if still the same filename will be -02, and so on and so forth) to the end of the file before the extension .plp.
example output:
filename.plp
filename-01.plp
filename-02.plp
filename-03.plp ~ filename-99.plp
This is my current code:
VB Code:
Function isFile(ByVal sFileName As String) As Integer On Error Resume Next Dim lFileLength As Long Const ATTR_NORMAL = 0 isFile = False If Dir$(sFileName, ATTR_NORMAL) <> "" Then lFileLength = FileLen(sFileName) If (lFileLength > 0) Then isFile = True End If End Function
VB Code:
Private Sub cmd_ok_Click() Dim prof As String Select Case Me.Caption Case "Save Profile" txt_profilepath.Text = file1.Path & "\" & file1.FileName & txt_plprofile.Text If isFile(txt_profilepath.Text) Then txt_plprofile.Text = frm_loadfile.var1 prof = frm_field.GetString(txt_plprofile.Text, "-", "C") If MsgBox("File " & txt_profilepath & " exists. Do you want to overwrite the current profile?{Y/N]", vbQuestion + vbYesNo, App.ProductName + " Prompt") = vbYes Then SaveProfile txt_profilepath.Text, pl1 Else txt_profilepath.Text = file1.Path & file1.FileName & "\" & prof & "-02" & ".plp" SaveProfile txt_profilepath.Text, pl1 End If Else MsgBox "Saving " & txt_profilepath & " as new profile." SaveProfile txt_profilepath.Text, pl1 End If profilepath = txt_profilepath.Text frm_field.cmd_next.Enabled = True Case "Load Profile" txt_profilepath.Text = file1.Path & "\" & file1.FileName MsgBox "Loading " & txt_profilepath & " profile." LoadProfile txt_profilepath.Text, pl1 profilepath = txt_profilepath.Text frm_field.cmd_next.Enabled = True End Select Me.Hide End Sub
HELP!!..![]()




seraphicmortal
if you deem this post helpful. 
Reply With Quote