Results 1 to 8 of 8

Thread: append/ ammend

  1. #1

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    hi,

    i have a text file called, hackingattempt.ooo first of all when the command button is clicked i need to kno if he file is there if it isn't i need to create it, once i have done this i want to apend this filw with the information from two labels and two textboxes, i have tried to use the following code to apend the file but it doesn't seem to work how can i inncorportae the information from the labels and text boxes into this file as well, and how do i check if he file excists ?

    Code:
    Open ("c:\hackingattempt.001") For Append As #1   
    a.writeline ("There was a invalid entry at")
    a.writeline Label3.Caption + Label4.Caption
    a.writeline text1.text + text2.text
        Close #1
    cheers to all that can help

    Merlin ¿

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  2. #2
    Lively Member
    Join Date
    Nov 2000
    Location
    Québec City
    Posts
    73
    I would try using Print instead of a.writeline...

    like:
    Open ("c:\hackingattempt.001") For Append As #1
    print #1, ("There was a invalid entry at")
    print #1, Label3.Caption + Label4.Caption
    print #1, text1.text + text2.text
    close #1

    That shoul work



  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Command1_Click()
        Dim intnum As Integer
        intnum = FreeFile
     'if it does not exist then create it   
        If Dir("c:\hackingattempt.001") = "" Then
            Open "c:\hackingattempt.001" For Output As intnum
              Print #intunm, "There was a invalid entry at"
              Print #intnum, Label3.Caption & Label4.Caption
              Print #intnum, text1.Text & text2.Text
              'if you are adding you use +
              'print #intnum, val(text1) + val(text2)
              'you may want a space if you are just joining
              'print intnum, label3.caption & " " & label4.caption
           Close #intnum
     'if it exists then append          
        Else
            Open "c:\hackingattempt.001" For Append As intnum
              Print #intunm, "There was a invalid entry at"
              Print #intnum, Label3.Caption & Label4.Caption
              Print #intnum, text1.Text & text2.Text
              'if you are adding you use +
              'print #intnum, val(text1) + val(text2)
              'you may want a space if you are just joining
              'print intnum, label3.caption & " " & label4.caption
           Close #intnum
        End If
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    krushstone - thanks that is brilliant i didn;t relise that you could put a print statement in it

    hesaidjoe, i like this one and i will use it but i have a problem with it when i run it and it creates the file i have the follwing error

    bad name or number

    with this line in both occurances in the code

    Code:
    Print #intunm, "There was a invalid entry at"
    any suggestions

    Merlin ¿

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Yep, it's because of this:

    Code:
            Open "c:\hackingattempt.001" For Output As intnum
              
    Replace it with 
    
    
            Open "c:\hackingattempt.001" For Output As #intnum
    
    Also for the Append one:
    
    Open "c:\hackingattempt.001" For Append As #intnum
    ok have fun Merlin!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    cheers jop i managed to fix it in the end by replaceing the intnum with #1 and this fixed it

    thanks anyway

    Merlin ¿

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I suggest using #intnum tho.. because that VB handles the FileNumber and always take a FreeFile number... but it's up to you wich to use
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  8. #8

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    cheers for your help )

    Merlin ¿

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width