Shoutbox

VB 6 User help - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: VB 6 User help (/showthread.php?tid=81153)

VB 6 User help by macbrutal on 01-23-2008 at 05:32 PM

Hi, i'm new at visual basic so you know..
My latest program is a Userprogram, and the coding is done
except that my files gets overwritten when i'm saving it..
----------------------------------------------------------------------------
Private Sub Command1_Click()
Dim namefile As String
namefile = Text1.Text

Open App.Path & "\Accounts\" + namefile + ".txt" For Output As #1
Print #1, Text1.Text
Print #1, Text2.Text
Print #1, Text3.Text
Print #1, Text4.Text
Close #1

MsgBox "Msgbox"
End Sub
------------------------------------------------------------------------------
Can you paste back the code but with the code so the file dont
get overwritten, please?


RE: VB 6 User help by freak544 on 01-23-2008 at 06:35 PM

if text1.text is the same each time then the file will be overwritten as your saving it as the same file name


RE: VB 6 User help by Spunky on 01-23-2008 at 06:47 PM

^o) If you want to add text to the end of the file use this instead, For Output overwrites/creates files, Input reads files and Append adds to files

code:
Private Sub Command1_Click()
Dim namefile As String
namefile = Text1.Text

Open App.Path & "\Accounts\" + namefile + ".txt" For Append As #1
Print #1, Text1.Text
Print #1, Text2.Text
Print #1, Text3.Text
Print #1, Text4.Text
Close #1

MsgBox "Msgbox"
End Sub