Any One Help me about UPDATING file in the Text .

Reply

Join Date: Jan 2009
Posts: 2
Reputation: regberds is an unknown quantity at this point 
Solved Threads: 0
regberds regberds is offline Offline
Newbie Poster

Any One Help me about UPDATING file in the Text .

 
0
  #1
Jan 15th, 2009
Guys i have problem about fle handling..
i dont know howto update the text in the file.. or in the NOTEPAD

this is my code..


Private Sub cmdUpdate_Click()
Dim ndx As Byte
Dim tmp As String

Open App.Path & "\data.txt" For Output As #1

Write #1, txtname, txtaddress, txtphone.Text
Close #1

lstcontact.RemoveItem (lstcontact.ListIndex)
lstcontact.AddItem (Chr(34) & txtname & Chr(34) & "," & Chr(34) & txtaddress & Chr(34) & "," & Chr(34) & txtphone & Chr(34))

Close #1,


End Sub


that's the code guys.. when i run the program.. never be update at

the text file... it will Rewrite all in side the text file all datea will replace a new data...

hope some one help me thanks ^^
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Any One Help me about UPDATING file in the Text .

 
0
  #2
Jan 15th, 2009
First problem: you didn't use code tags. you can do that by typing (without the added spaces):
[ code=vb ]
' your vb code here
[ /code ]

Second Problem: it seems you are closing your file two times, but only opening it once... Tsk, Tsk.

Lastly, it seems that UPDATE is not the right word.... I think you mean "append", where it will write 1 line... then again another line. UPDATE would mean you are changing something already in the file.... here you simply want to add something to the file (or am I mistaken)? For this, you would probably want:
  1. Private Sub cmdUpdate_Click()
  2. Dim ndx As Byte
  3. Dim tmp As String
  4.  
  5. Open App.Path & "\data.txt" For APPEND As #1 ' // yeah, for append
  6. Write #1, txtname, txtaddress, txtphone.Text
  7. Close #1
  8.  
  9. lstcontact.RemoveItem (lstcontact.ListIndex)
  10. lstcontact.AddItem (Chr(34) & txtname & Chr(34) & "," & Chr(34) & txtaddress & Chr(34) & "," & Chr(34) & txtphone & Chr(34))
  11.  
  12. End Sub
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 2
Reputation: regberds is an unknown quantity at this point 
Solved Threads: 0
regberds regberds is offline Offline
Newbie Poster

Read Please....

 
0
  #3
Jan 15th, 2009
yeah your right .. but when i use append it will add again..like this


name: rejay
Address: USA
Phone : 123


other Data:

Name: berdos
Address: Canada
Phone:321


When i use append it will Appear like this ...

the file i want to Change..

Name: berdos
Address: China
Phone:321

This is inside the file in the Text

"rejay"," USA "," 123" / / First data
"berdos","Canada","321" / / Second Data
"berdos","China","321" // 3rd Data <---- this is my

problem when i use Append ....






my point is i want to change the previous File in the text like

this example ...


name: rejay
Address: USA
Phone : 123

other Data:

Name: berdos
Address: Canada
Phone:321




This is inside the file in the Text

"rejay"," USA "," 123" / / First data
"berdos","Canada","321" / / Second Data



so... i want to change the ADDRESS of Second Data... CANADA to CHINA like this..

name:berdos
Address: CHINA
Phone: 321


so the Output it will like this


This is inside the file in the Text

"rejay"," USA "," 123" / / First data
"berdos","CHINA","321" / / the NEW Second Data


see... . that's what i mean... i want to change the prevous data..

hope you understand...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC