0

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..

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by macbrutal
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.