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 "Thank you for your registration, please login!"
Form2.Show
Form1.Hide

End Sub

--------------------------------------------------------------------------
That's the code i use..
Problem : if i create another 2 users with the same username(datafile)
Then it gets overwritten, which i dont want it to get... Any ideas how to make it say
msgbox ="Username already exists" ? Thanks..

Recommended Answers

All 2 Replies

namefile = App.Path & "\Accounts\" & Text1.Text & ".txt"

if Dir$(namefile) <> "" then
msgbox ="Username already exists"
else
Open namefile For Output As #1
...
...
end if

To avoid any potential conflicts in file numbers, you should use the FreeFile function:

fileNumber = FreeFile()
Open namefile For Output As #fileNumber

Bah..Doesnt work for me >.<
Could you actually paste the whole code here then i will read it that way, please?
Would appriciate that :)

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.