Help correct them please.

Theera

Well-Known Member
Licensed User
Longtime User
Hi all,
I need to add a new line of items into RiceName.txt as below:-
If File.Exists(File.DirDefaultExternal,"RiceName1.txt") Then
Dim Writer As TextWriter
Writer.Initialize(File.OpenOutput(File.DirDefaultExternal,"RiceName1.txt",True))
Writer.WriteLine(TxtRRName.Text & "," & TxtUUPrice.Text )
Writer.Close
End If

I have problem Why not add another line?

Before-Add :- information is
aaa,20
bbb,30
ccc,40

After-Add :- information is
aaa,20
bbb,30
ccc,40ddd,50 <= Error information

Please correct them.

Best Regards
Theera
:sign0085:
 

Theera

Well-Known Member
Licensed User
Longtime User
The thread title should summarize the question.

WriteLine adds a new line character at the end. If you need to add at the beginning then you should write:
B4X:
Writer.WriteLine(CRLF & TxtRRName.Text & "," & TxtUUPrice.Text)

Hi Erel,

I have ever coded this code before. The first time is o.k. and the second time for addition ,it has error occured according to attached file.

Best Regards
Theera
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I didn't see something really wrong in this coding. I think Erel is right, since the error probably is somewhere else in your string-processing routine. See the attached file.
 

Attachments

  • writer.zip
    6.7 KB · Views: 182
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
I didn't see something really wrong in this coding. I think Erel is right, since the error probably is somewhere else in your string-processing routine. See the attached file.

Hi MC73,
Thank you for example. I don't understand that After I input data and press button ,the information is display,but I re-run the wiget again,the information which I need to display should be below:-

Before-Re-run:
aaa,20
bbb,30
After-Re-run
ccc,40 <= prior data is lost

it should be below:

aaa,20
bbb,30
ccc,40

Best regards
Theera
:eek:
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Hi MC73,
Thank you for example. I don't understand that After I input data and press button ,the information is display,but I re-run the wiget again,the information which I need to display should be below:-

Before-Re-run:
aaa,20
bbb,30
After-Re-run
ccc,40 <= prior data is lost

it should be below:

aaa,20
bbb,30
ccc,40

Best regards
Theera
:eek:

Using the example I've sent, nothing like this is happening. Check if you have somewhere, code for recreating your txt file. Or you can upload a zip file containing your code, so that members of this forum can help you.
 
Upvote 0
Top