Solved

Visual Basic question

Posted on 1997-09-09
3
209 Views
Last Modified: 2013-11-25
How do I get a text box on a form to save as a text document
using, a 3d command button using it as a save button? How do
I code this so that i can reopen the same file without it
being scrambled and unreadable?
0
Comment
Question by:iriqus
[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
3 Comments
 

Expert Comment

by:superjohan
ID: 1434483
Not a clue...
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1434484
iriqus: reject superjohan's ridiculous answer, and then we can deal with this.  Basically, you need to access the text box .text property, and using basic's file i/o, actually write that text to disk as a file.  Usually you need to have a file name and path designated, which you can obtain using the common dialogue control.  Just reject the above answer, and I or someone else who really knows will give you specific answers.
0
 

Accepted Solution

by:
hjack earned 50 total points
ID: 1434485
you have a couple things to consider here.
1. a textbox's text property can hold up to 32,766 characters
2. a string can only hold 255

this should read it in:
Private Function DataConverter( myfile As String)

Dim  InFileNo As Integer, Rec As String

On Error GoTo Dconvert



   
InFileNo = FreeFile
Open myfile For Input As #InFileNo



Do While Not EOF(InFileNo)
    Rec = Input$(255, InFileNo)
    myTexbox.text = myTextbox.text & rec
Loop

Close #InFileNo

Exit Function

Dconvert:
    Select Case Err
        Case Else
            Resume Next
       
    End Select
End Function


some variation of this should work to write...


Private Function DataConverter( myfile As String)

Dim OutFileNo As Integer, Rec As String


On Error GoTo Dconvert
   

OutFileNo = FreeFile
Open strTempFile For Output As #OutFileNo



Do While Not (intoffset > len(mytextbox.text)-255)

    Rec = mid(mytextbox.text,intOffset,255)
    Write #OutFileNo, Rec
 
Loop


Close #OutFileNo
Exit Function

Dconvert:
    Select Case Err
        Case Else
            Resume Next
       
    End Select
End Function


you should also look into these i.o. operators..

get  -- reads data
put --- writes data
print # --- writes data
LOF-- length of current file
EOF-- checks for end of file
Reset-- closes all files..

hope this or some variation could help..

jack

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

728 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