?
Solved

Saving and opening Text

Posted on 2003-03-15
3
Medium Priority
?
204 Views
Last Modified: 2010-04-17
Hello
This is alex and i am a beginger :( in VB.
I made a imitation of notepad. I have gotten it to print and chage fonts ect..
I have not been able to get it to save or open files.
I want it to Save/Open the text in the textbox but cant figure out how.
The textbox is caled TextBox The Save butten is called save and the open butten is caled save.
Open to ideas
Thanks
0
Comment
Question by:AAbomber98
  • 2
3 Comments
 
LVL 2

Expert Comment

by:JoaTex
ID: 8145050
Hi

Here is the code:

Private Sub CommandOpen_Click()
    Dim A As String
    Open App.Path & "MyText.txt" For Input As 1
    A = Input(LOF(1), 1)
    Close 1
    TextBox.Text = A
End Sub

Private Sub CommandSave_Click()
    Open App.Path & "MyText.txt" For Output As 1
    Write #1, "TextBox.Text"
    Close #1
End Sub

Jo
0
 

Author Comment

by:AAbomber98
ID: 8146507
Sorry i tryed but i did not work.
it would print "TextBox.text" in the textbox when i tryed to open it.

i would also like to able to specify and name where and what i want to call it.

Thanks
0
 
LVL 2

Accepted Solution

by:
JoaTex earned 150 total points
ID: 8149120
Hi
Sorry about that here is the corrected code

Option Explicit

Private Sub CommandOpen_Click()
   Open App.Path & "\MyText.txt" For Input As #1
   TextBox.Text = Input(LOF(1), 1)
   Close #1
End Sub

Private Sub CommandSave_Click()
   Open App.Path & "\MyText.txt" For Output As #1
   Print #1, TextBox.Text
   Close #1
End Sub

to change the directory just put on line [open] your directory Ex:
Open "c:\MyText.txt" For Output as #1 'This to save, and the same to open

About the file .txt call it Whatever you want.
Jo
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Six Sigma Control Plans
Screencast - Getting to Know the Pipeline

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question