(urgent - please help) reading and writing in a text file using VB 
Author Message
 (urgent - please help) reading and writing in a text file using VB

Hi,

I need to write 5 words in a text file without owerwriting the existing
words.
each word must be separated by a coma.

a file contains :

mike;mikie;22;france;student
flora;florie;19;spain;employee

i need to insert : name;surname;age;country;job

then it will be like this  :

name;surname;age;country;job
mike;mikie;22;france;student
flora;florie;19;spain;employee

but the program has to detect if the first line
(name;surname;age;country;job) is already inserted. If it is, vd does
nothing. if not, then vb inserts this line without overwriting the other
lines.

please help. very important for me. thanks. mike



Fri, 12 Oct 2001 03:00:00 GMT  
 (urgent - please help) reading and writing in a text file using VB
Hi  Mike,

There are a couple of ways to do this.

here is one way

Private Sub CheckFile(ByVal FilePath As String)
    Dim iFnum as Integer
    Dim iPos    as Integer
    Dim strFileText As String

    iFnum = FreeFile

    Open FilePath For Input As iFnum
    strFileText = Input(LOF(iFnum),#iFnum)
    Close #iFnum

    If Len(strFileText ) <> 0 then
        iPos = Instr(1,strFileText,"name;surname;age;country;job")
        If iPos = 0 then
            strFileText = "name;surname;age;country;job" & vbCrLf &
strFileText
        End If
        iFnum = FreeFile
        Open FilePath For Output As iFnum
        Print #iFnum, strFileText
        Close #iFnum
    End If
End Sub

Regards,

Andrew



Fri, 12 Oct 2001 03:00:00 GMT  
 (urgent - please help) reading and writing in a text file using VB
open the file for append.
Quote:

>Hi,

>I need to write 5 words in a text file without owerwriting the existing
>words.
>each word must be separated by a coma.

>a file contains :

>mike;mikie;22;france;student
>flora;florie;19;spain;employee

>i need to insert : name;surname;age;country;job

>then it will be like this  :

>name;surname;age;country;job
>mike;mikie;22;france;student
>flora;florie;19;spain;employee

>but the program has to detect if the first line
>(name;surname;age;country;job) is already inserted. If it is, vd does
>nothing. if not, then vb inserts this line without overwriting the other
>lines.

>please help. very important for me. thanks. mike



Sat, 13 Oct 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. (urgent - please help) reading and writing in a text file using VB

2. Reading from a text file and writing toa text file from Vis Bas 6.0

3. Reading and Writing to .ini files - help please.

4. any help please....fastest way to read and write files

5. HELP: Reading and Writing to text files

6. part II of need help reading writing text file

7. Need Help Reading and Writing to text file

8. Writing comma delimited text files using double quotes - Write Statement

9. Please help with Speed of Text File READ

10. Problem Reading Text File - Please Help!

11. Write Text File to XBASE database using VB

12. Help please....Urgent VB crashes using RDC.

 

 
Powered by phpBB® Forum Software