Stream Reader and Stream Writer.

dave_ie

Member
Joined
Mar 27, 2010
Messages
24
Programming Experience
Beginner
ok, im stuck at this one,

1. user clicks on Items, Items are add to the list box

2. User Sets up Account, if they dont have one already.

3. Users Details are saved in a Text file,

4. users Items are saved in a Different text file.

5. user Logs on with Username and password.
(Msgbox pops up and Welcomes him)

6. Users Details & Items are now Saved in a new text file.

my Question is how do i do Step 6?

Get <fileName> open <filename> Save as new <filename>

should i be opening the two files reading from them with Readline() to end.
but how do i make sure that only the Current Users Details are saved not every User that may be saved in the Text file?
 
VB.NET:
6. Users Details & Items are now Saved in a new text file.
    A. Check for user file
           i. User file exists
                a. Load information                
           ii. Doesn't exist
                a. nothing to do yet
     B. Append new information to information memory(if any)
     C. Save file (overwiriting if existing)
 
I think an xml file would do you more justice. You can make new element sections with each new user and when saving you only change the specific user's elements. I know there is learning here, but in the long run much easier.
 
i was looking at the Xml, filing but it means going back over 4 forms of code and change them all to allow to read xml filing,

another thing, Showing users Name on a Message box, am i right in this?

VB.NET:
  If My.Computer.FileSystem.FileExists(AccountLocation) Then

            Dim Input As New IO.StreamReader(AccountLocation)
            Input = File.OpenText(AccountLocation)

            input.readline("Firstname=")

            Input.Close()

            If Login(Username.Text, password.Text) Then
                MessageBox.Show("Welcome!", convert.tostring("Firstname="))
 
I totally understand - been there done that, wore out the t-shirt. After I switched life has been so much easier and don't regret the work at all. As to your question if the variable is a string (and one would think so):

VB.NET:
MessageBox.Show(Firstname)
 
ok. once i have this Program done and finished with, I will read more into XML and database filing,

ok as the Text file stands,

opening both Users and Saved text files
VB.NET:
            Dim Input As New IO.StreamReader(AccountLocation)
            Input = File.OpenText(AccountLocation)

            Dim lvInput As New IO.StreamReader(Saved)
             lvInput = file.AppendText(Saved)


input close()
lvinput close()
for reading from AccountLocation
VB.NET:
file.readline("firstname=")
flie.readline("Secondname=")
file.readline("Email=")
file.readline("Address=")
file.readline("Telephone=")
file.readline("Work Number=")
file.readline("Ext.Number=")

for Writing to Saved
VB.NET:
file.Writeline("firstname=")
"                "("Secondname=")

is this the right way about it?
 
Im getting Firstname is not declared

if i do

VB.NET:
Dim Firstname as String

the whole thing give me and blue underline code error
 
ok, i fix the Error
VB.NET:
Dim Firstname  As String

firstname = input.readline()

ok i enter in a second user into my Account File why are their 0 showing at the end of the First user details

and when i log in and save the Information on the Current user logged into the Program it seems to be only Saving the first Users Details not the Second nor third user.

How do i get it to save the Current user details with Writeline()?
 
Back
Top