Hello,

I'm currently making a program in Visual Basic 2010 for my Course work, and I'm struggling a little as it involves a "log-in system."

The system will save the Users Information in a folder (Called UserInfo.txt) (Address, Password, Email etc..), and the folder name being the username of the User.

When an Admin wants to view or edit a User, I want the Admin to be able to select the User from a drop-down list and when selected, the information of the user loads in and is displayed in the text boxes bellow (on the same form). The Information can then be edited and Saved back to the file of that user selected with a "Save" button.

Could somebody please help me, as I'm struggling!

Thanks a lot!

- Toby.

Recommended Answers

All 7 Replies

You don't want to read a file from multiple folders, just to read a file and populate the appropriate textboxes. According to your specs there is only 1 file per directory and that is the userinfo.txt.
Since you are not giving any specs for the file itself read here: http://www.daniweb.com/software-development/vbnet/threads/134617 and here http://www.homeandlearn.co.uk/net/nets8p3.html for plain text file and here: http://www.daniweb.com/software-development/vbnet/threads/380681 for a csv file (I know the extension isn't csv, but still it's a text file).
For the users (which directory to use for reading the correct file), read here: http://msdn.microsoft.com/en-us/library/c1sez4sc.aspx or in general the directory class here: http://msdn.microsoft.com/en-us/library/system.io.directory.aspx

commented: ok +1

try this

public sub ListFiles()

'DIR for folder
'add each file to ListBox control

For each file as string in IO.directory.getfiles(Folder Path)
	Listbox.items.Add(file)
next

End Sub

Thank you very much - both of you :)

Although @ Adam, I do want to take a file from multiple folders, because The same file name will be in all the folders, and this file will store all of the information about the user. When a Admin is to edit the users Info, he will select the username from the listbox (or the folder name) of the user, and then this will populate the textboxes bellow. When the data is edited, the Information will be resaved in the correct folder.

Following is the txtFile Layout:

Username (Tobyjug2222)
Password (hello)
Account type (Admin)
Reward Points (1000)
Tutor Room (12HY)
Date of Birth (02/01/94)
First Name (Toby)
Last Name (Daniel)
House Number (4)
Street (Yellow Brick Road)
Village (Old Village)
Town (Goonie)
County (Cheshire)
Post Code (CH1 6RB)


@Obsys, I was struggling to get your method to work because the reader wouldn't read it as a string, although it *was* decleared as a string.. when Debugging/ trying to find the error, I msgbox'ed the file path to see what it would display, and it gave me a "Argument 'Prompt' cannot be converted to type 'String'." & crashed.

Do you know how I can fix this? :o

Thanks

- Toby.

Try making a file with a list of all the usernames and there corresponding directory.
Populate the drop down box with this list of usernames.
When a name is selected then read the corresponding folder and open the file inside this folder.
There are tutorials everywhere for reading and writing from text files in VB .Net such as http://zorabyte.com/VBNETTutorials/ReadFileLineByLine.aspx

Let me know how it all goes!

Bernie.

Hi Bernie,

I was working on your Method over the last few days, and I created the file to store/ write all the users in, although I bumped into one problem, and that was how to give the User a path, that was connected to the username in that file.

Any way you know, on how to do that?

Thanks a lot!

- Toby.

I was thinking of setting the file with usernames and paths included.
e.g.

Username Path
bernie d:\somedir\users\bernie\
david d:\somedir\users\david
etc...

Just a tab delimited text file

Then read in the file and split the lines into a 2 element array. Do this in the load form section so it's ready to go when someone selects a user from your form.

Then, loop through the array when someone selects a user until you get to that user and use the path for however you want.

I hope I answered your question.

Let me know how it all goes.

Thanks, Bernie.

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.