Displaying contents of an ASCII file in VB

Electronics Computer Programming Q&A
Post Reply
User avatar
CeaSaR
Posts: 1949
Joined: Sat Nov 08, 2003 1:01 am
Location: Phoenixville, PA USA
Contact:

Displaying contents of an ASCII file in VB

Post by CeaSaR »

Hello everyone,<p>I need to be able to show the contents of an ASCII text file in a scrollable (sub)window on my main form. The "window" will become visible when a text control is clicked and invisible when another text control loses focus. I have that part worked out, but cannot figure out how to get the entire contents of the text file to show up in the "hideable" textbox. The file is approx. 40 pages of listings. If that is too long, would I be able to use a combobox or something like that to search the file for the correct listing and display just that one? If so, how would I do that?<p>I am currently using VB1.0 (Windows) for this project. I have VB4 but cannot install it right now, however a solution for that platform would be appreciated also.<p>Thanks in advance for any help.<p>CeaSaR<p>P.S. Does anyone have the help file for VB1.0 for Windows? Mine is corrupted. I can't read it at all on any computer under any OS. Thanks.
Hey, what do I know?
greg123
Posts: 361
Joined: Sat Sep 07, 2002 1:01 am
Location: St. John's NFLD Canada
Contact:

Re: Displaying contents of an ASCII file in VB

Post by greg123 »

Cesar,<p>Is your text box set to multi-line?<p>You can then open the ascii file and place it directly into the text box.<p>Open "C:\youfile.txt" for input as #1
Input #1, text1.text
Close #1<p>Will read it all into the text box.<p>Does Vb1.0 offer the Rich Text Box? I am using VB 6.0 and .Net so i cant check.<p>Greg<p>[ March 11, 2004: Message edited by: Greg ]</p>
User avatar
CeaSaR
Posts: 1949
Joined: Sat Nov 08, 2003 1:01 am
Location: Phoenixville, PA USA
Contact:

Re: Displaying contents of an ASCII file in VB

Post by CeaSaR »

Greg,<p>Tried your suggestion:<p>Sub Text7_GotFocus ()
frame5.visible = true
text9.visible = true
Open "soilname.txt" For Input As #1
Input #1, text9.text
Close #1
End Sub<p>Comes up with an error highlighting the period between text9 and text saying invalid use of object. Obviously everything up to there works. I'm thinking VB 1.0 is the real culprit. I am also trying to shadow a set of option buttons on a black and white form for printing and it won't let me do it. Maybe it's time to bite the bullet and get a bigger hard drive for VB 4.
BTW, multiline = true with scrollbars hor and vert. Rich text... I don't think so. No help file, so I can't tell for sure and I haven't found it in any menu, anywhere.<p>Thanks,
CeaSaR
Hey, what do I know?
greg123
Posts: 361
Joined: Sat Sep 07, 2002 1:01 am
Location: St. John's NFLD Canada
Contact:

Re: Displaying contents of an ASCII file in VB

Post by greg123 »

Does VB 1 support the .Visible property?<p>If not, they try using the enabled property. It's nicer anyway, hiding a control is ugly.<p>What about a picture box? You can print the contents to a pic box or even on the form with Me.Print var<p>Greg
User avatar
CeaSaR
Posts: 1949
Joined: Sat Nov 08, 2003 1:01 am
Location: Phoenixville, PA USA
Contact:

Re: Displaying contents of an ASCII file in VB

Post by CeaSaR »

I have found that VB1 is a pain in the a** because of its limited abilities. It worked great for the slot machine that someone posted about awhile back (was it this board or another???) as it allowed scrolling of the pictures AND the totals (both the money and the # of times played), but to get the code worked out for everything, UGH! That and the fact that you can't use JPG's (BMP's only!), no simple line drawing ability (lines on a form must be drawn in code), etc., etc.<p>As soon as my new HDD comes in VB4'll be installed. Thanks for the effort anyway.<p>CeaSaR
Hey, what do I know?
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests