Solved

Visual Basic question

Posted on 1997-09-09
3
208 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

726 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