?
Solved

Saving and opening Text

Posted on 2003-03-15
3
Medium Priority
?
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Progress

762 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