PDA

View Full Version : How to save data from text fields and checkboxes to a file?


D0M1N0R
10-02-2006, 07:22 AM
Id like to theese things:

1:
Have multiple input fields which by default has different values and can be changed and save to a text file.
i.e. if it exists a file.txt in my docs folder, which already has for example Name myname, age myage, and so on in it, to then have a three input fields, one for name and one for age. When something is entered into it and the save button is pressed it overwrites the current values in the file.txt.

2:
Have a reated feature but instead of an input field, have a dropdown box with preset values, i.e. for age, like beeing able to select groups of 10-20, 20-30, 30-40 and so on, and then saving that value to the same file.txt

3:
Having a dropdown box which lists all existing files of a certian type within a folder. i.e. that you can select between all .txt files in e.g. docs\textfiles and then edit them or having their values loaded into some input field or related. Mainly having the feature of listing the files and then allowing their content to be shown.

azmanar
10-02-2006, 08:19 AM
hi,

Take a look at some samples in this site (http://azman.info/ams). You might find something useful for your purpose.

D0M1N0R
10-02-2006, 08:22 AM
Yeah, I know, working with it, almost gotten the first one finished, How can I tell it to print the following variables to a new line?

e.g.
Text2BeSaved="Headline "..1stparagraph.." "..2ndparagraph.."";

Thereby having it saved like
Headline
1stparagraph
2ndparagraph

Just as simple as \n and such,, but how?

TJ_Tigger
10-02-2006, 08:40 AM
Just as simple as \n and such,, but how?

With windows you will wnat to use a \r\n.

Text2BeSaved="Headline \r\n"..1stparagraph.."\r\n "..2ndparagraph.."";

Tigg

D0M1N0R
10-02-2006, 08:48 AM
Ok, thanks, was just trying out that, but it wouldnt accept "\r\n", but just \r\n works fine :yes

TJ_Tigger
10-02-2006, 09:22 AM
Ok, thanks, was just trying out that, but it wouldnt accept "\r\n", but just \r\n works fine :yes

You need to make sure that the \r\n is contained within a string.

GOOD
Text2BeSaved="Headline \r\n"..1stparagraph.."\r\n "..2ndparagraph.."";

BAD
Text2BeSaved="Headline "\r\n..1stparagraph..\r\n" "..2ndparagraph.."";
Tigg

D0M1N0R
10-02-2006, 09:40 AM
Yep.

Ive got the first and second points working, anyone got a clue on this?

Having a dropdown box which lists all existing files of a certian type within a folder. i.e. that you can select between all .txt files in e.g. docs\textfiles and then edit them or having their values loaded into some input field or related. Mainly having the feature of listing the files and then allowing their content to be shown.

TJ_Tigger
10-02-2006, 10:04 AM
Having a dropdown box which lists all existing files of a certian type within a folder. i.e. that you can select between all .txt files in e.g. docs\textfiles and then edit them or having their values loaded into some input field or related. Mainly having the feature of listing the files and then allowing their content to be shown.

Certainly. Use the File.Find command to find all the .txt files in the directory you want to use. This will return a table which you can parse using a for loop to step through each item and add them to a ComboBox. As you step through the table I would use String.SplitPath to break the file drive/path/filename/extension into its separate parts and then add the filename as the text item to the combobox and the full path as the data. That way when you want to open the file you can use the data portion of the combobox to open the file.

HTH
Tigg

TJ_Tigger
10-02-2006, 10:05 AM
BTW azmanar's site has a lot of good examples showing how to do this kind of stuff too.

Tigg

lnd
10-02-2006, 12:45 PM
Good Luck From Lnd The File In Attach

D0M1N0R
10-02-2006, 02:24 PM
Lots of thanks :D