| | |
Any One Help me about UPDATING file in the Text .
![]() |
•
•
Join Date: Jan 2009
Posts: 2
Reputation:
Solved Threads: 0
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 ^^
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 ^^
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:
[ 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:
vb Syntax (Toggle Plain Text)
Private Sub cmdUpdate_Click() Dim ndx As Byte Dim tmp As String Open App.Path & "\data.txt" For APPEND As #1 ' // yeah, for append 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)) End Sub
•
•
Join Date: Jan 2009
Posts: 2
Reputation:
Solved Threads: 0
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...
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...
![]() |
Similar Threads
- Updating a file: setting the offset (Perl)
- how to validate text file, loading into listbox (Visual Basic 4 / 5 / 6)
- conversion of text file into data base file (Visual Basic 4 / 5 / 6)
- Beginners help to migrate from Access to MS SQL fomr VB (Visual Basic 4 / 5 / 6)
- Writing to certain position in a file (C)
- Formatting clipboard text for spreadsheets (Visual Basic 4 / 5 / 6)
- HighJackThis File Log, Help Needed. (Viruses, Spyware and other Nasties)
- help with updating a text file using C++ (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Substraction code in MSFlex Grid
- Next Thread: Userprofile
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






