|
-
Dec 11th, 2005, 11:26 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Output to a text file ..
well i have a workspace in which i keep track of command buttons clicked by user and save them( names of those command buttons ) in a text file ( each name one on next line of this text file ) ... now i want to append a word "new" at very first line of that text file every time my program runs .. how can i do that without disturbing rest of the subs ? ..
-
Dec 11th, 2005, 11:36 AM
#2
Thread Starter
Addicted Member
Re: Output to a text file ..
plz Discard the previous post . i didnt know i can be such a stupid at times . anyway .. now i want that when my user clicks on a picturebox at run time my program pops out a window for him . in which my user enters any text and then my program saves that data in a text file ( line by line for each picturebox clicking ) . i hope i ll be making sense ..
-
Dec 11th, 2005, 11:41 AM
#3
Addicted Member
Re: Output to a text file ..
First off, how did you append "new" to the beginning of the text file? So, if I'm right, a text file with content:
Code:
Button1
Button2
etc
would become
Code:
new
Button1
Button2
etc
as opposed to
Code:
Button1
Button2
etc
new
?
As for the picturebox, maybe
Code:
Private Sub Picture1_Click()
Dim FF as integer
Dim TextIn as string
FF=freefile()
TextIn = InputBox("Input value please")
Open "C:\Output.txt" for Append as #FF
Write #FF, TextIn
Close #FF
End Sub
?
-
Dec 11th, 2005, 12:03 PM
#4
Thread Starter
Addicted Member
Re: Output to a text file ..
well arby . yeah the scenarios u showed were exactly what i wanted to do .. and for appending "new" to begining .. i simply created another command button . and captioned it as " press to start" and named it as "start " so that user clicks it after running first .. and then i created a sub like
VB Code:
Public Sub start()
Print #FF, "New"
End Sub
where FF is the same file i m using for storing other values ..
simple naa
well i think the code you have given me right for me but what if Picture1 is a control array ( as i have in my case ) .. i have it instances in my workspace ... what will i do then
-
Dec 11th, 2005, 12:06 PM
#5
Addicted Member
Re: Output to a text file ..
Ahh, I see, nice one ^_^
As for the Control array bit... err, that's where i get off the VB knowledge train, i'm still a newbie ^^;; .. We haven't covered Control Arrays yet, hopefully someone can suggest a modification though ^_^ Sorry about that
-
Dec 11th, 2005, 12:15 PM
#6
Thread Starter
Addicted Member
Re: Output to a text file ..
its ok .. i m more Goof to VB then another single individual over here .. and its been a lil time since i have been eating their brains and everybody here is real nice to help me out every time
i m waiting for some other GURU to suggest me any solution of my problem ..
-
Dec 11th, 2005, 12:34 PM
#7
Re: Output to a text file ..
It doesn't matter if you use a Control Array or not the code would be the same. However I would use Print #FF, sTheText instead of the Write # statement.
-
Dec 11th, 2005, 12:35 PM
#8
Thread Starter
Addicted Member
Re: Output to a text file ..
Forget it .. did this too .. thanks a bunch to everybody
-
Dec 11th, 2005, 12:37 PM
#9
Addicted Member
Re: [RESOLVED] Output to a text file ..
How did you do it differently?
And JA, What's the diff wetween Write and Print (where it involves outputting to a file?) Just out of interest
-
Dec 11th, 2005, 12:49 PM
#10
Re: [RESOLVED] Output to a text file ..
 Originally Posted by Arby
How did you do it differently?
And JA, What's the diff wetween Write and Print (where it involves outputting to a file?) Just out of interest 
There is no real difference in the code itself. The only difference is that in a control array all picture boxes share the same Click event, but that just means that he only needs to write the code in one click procedure instead of the same code for each of the picture boxes.
-
Dec 11th, 2005, 12:55 PM
#11
Re: [RESOLVED] Output to a text file ..
The Write # statement will put the string inside quotation marks.
-
Dec 11th, 2005, 12:58 PM
#12
Thread Starter
Addicted Member
Re: [RESOLVED] Output to a text file ..
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
|