Click to See Complete Forum and Search --> : List Box? or Text Box?
July 25th, 2000, 09:33 PM
Hi.
I'm having problems with a program I'm trying to write.
I want to open a text based file with a file extension that's not .txt and then be able to create a find button to search for words listed in a separate text box.
I have created the UI and I can successfully open these files and see them using a list box combined with a common dialog box.
But I can't add a vertical scroll to this list box. And since I'm editing a text file (even though the extension is not .txt) I'm wondering if I should be using a text box instead of a list box?
I've tried using a text box. But for some strange reason. It won't display these files because the file extension isn't .txt. Even when combined with a common dialog box set up to filter the proper file extension. What's the deal with that? It works with the list box option.
Any advice?
It's just a text editor. But since the files don't have a .txt extension. I can't find any examples for this kind of thing.
Thanks.
makai
July 26th, 2000, 01:00 AM
This is from VB help
A ListBox control displays a list of items from which the user can select one or more. If the number of items exceeds the number that can be displayed, a scroll bar is automatically added to the ListBox control.
I have something like yours and it auto scrolls vertically
July 26th, 2000, 11:40 AM
Thanks for the reply.
But I just discovered something interesting.
Apparently. Using a text box in place of a list box WILL read a text based file.
The reason I didn't see the file contents displayed is because there is a file size limit that a text box can handle.
If a file is text based. It does not matter what the extension is. The common dialog command will handle it. But even if I increase the MAX file size I can only read limited sized text files in the text box.
Anyone know how I can display a large text file (600k) in the text box?
Thanks.
P.S. -This kind of information should be discussed in the newbies section of this site. This is not fun having to find this stuff on my own. And this is very important and needed info for us beginners.
Once I learn all the info needed. I plan on posting a detailed tutorial for newbies to be able to easily display and edit any type of text based files.
khaldac
July 26th, 2000, 12:57 PM
Try using the RichTextBox control. As far as I can tell, it should handle files the size you mention. You'll need to add the Microsoft Rich Textbox Control 6.0 (SP3) to your project. You'll also want to tell it to use .txt files instead of .rtf files and to add scroll bars. Use the control properties to do this.
July 26th, 2000, 02:01 PM
Thank you for the Info.
I was wondering if Rich text would do it. And you just confirmed it for me.
One more problem solved in a list of many.
Man it sucks to be a newbie ;-).
Thanks.
July 26th, 2000, 04:51 PM
ACK!
Using Rich text works as far as opening and reading the files now. But it changes the layout(format)of the files and if I save it like that. They won't work in the program they are designed to run in.
Is there a way to read a non-rich text file using the rich text box option. without VB actually converting the file to rich text?
I don't see any options in the prefrences for that.
Sorry to be such a pain.
Thanks.
khaldac
July 26th, 2000, 05:04 PM
Hmm, what kind of formatting are you referring to? A text file, by definition, has no formatting, with the exception of tabs and spaces. The Rich Textbox Control seems to preserve those, at least it did in the test I just ran.
July 26th, 2000, 06:29 PM
Well. Believe it or not. You just helped me again. ;-)
After you said that. I looked for anything out of the ordinary with the files. And sure enough. The problem is that these files contain the symbols { and } to enclose statements.
These text files are 3d graphics files. With an .obj file extesion.
The files are listed in a column which is good and the way I want them. But when I open them with the Rich Text option in VB. Those symbols cause the format to spread out horizontally.
Of course when I save them they are then not formated in a single column like they were before VB opened them.
Is there any way to deal with those pesky {} symbols on opening them without deleting them to maintain my formatting? Maybe I should use the list box option after all?
Thanks for the help.
You've helped me learn some interesting things today.
khaldac
July 26th, 2000, 06:49 PM
I just ran an experiment and as I suspected those {}'s in your files are placeholders for formatting commands. Or at least they are more than just the {} characters. Stripping them out would be no real challenge, but of course that would destroy your formatting. Do you have access to the file format for these files? Or will the manufacturer of the program used to create them tell you the function of these characters? If so, it might be possible to compensate for them. Still, it will entail a fair amount of work and might be more trouble than it's worth. If the listbox solution will work for you, I'd try that first. Sorry I couldn't be more help.
July 26th, 2000, 09:11 PM
That's OK. I did learn some new things by messing around with this project.
Those {}'s must remain in the text where they are. And the List Box option is very unflexable for me at this time. So I guess I'm outta luck.
I know it's possible to do this because I've got programs that do it. Made by other users. I just don't have the code to see how they did it.
Thanks for the help.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.