|
-
Nov 11th, 2000, 09:53 AM
#1
Thread Starter
Fanatic Member
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]
-
Nov 11th, 2000, 10:08 AM
#2
Lively Member
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
-
Nov 11th, 2000, 10:12 AM
#3
_______
<?>
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
-
Nov 11th, 2000, 10:38 AM
#4
Thread Starter
Fanatic Member
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]
-
Nov 11th, 2000, 12:02 PM
#5
Frenzied Member
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.
-
Nov 11th, 2000, 12:09 PM
#6
Thread Starter
Fanatic Member
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]
-
Nov 11th, 2000, 12:13 PM
#7
Frenzied Member
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.
-
Nov 11th, 2000, 12:24 PM
#8
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|