?
Solved

Visual Basic question

Posted on 1997-09-09
3
Medium Priority
?
210 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 100 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 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