Posts: 142
Threads: 33
Joined: Dec 2001
Ive managed to get a copy of VB6. its pretty similar to qb, but the whole gui thing is perfect for what im doing. im reading text out of a file and printing it to a 'form'
if i put it in a text box
eg
Code:
for i=1 to last
Text1.Text=name(i)
Next
it appears to over write every thing and only put the last thing in!
if i just use print
eg
Code:
for i=1 to last
Print name(i)
Next
it will put stuff of da bottom of da screen. i want it to have scroll bars if there is too much data for da screen!
There is a Multiline property in da text box options but it dosnt seem to do anything...
Posts: 1,752
Threads: 21
Joined: Jun 2002
Code:
for i=1 to last
Text1.Text=Text1.Text+chr$(13)+chr$(10)+name(i)
Next
You might not need chr$(13)+chr$(10) in there...haven't done any VB in a long time...
Posts: 142
Threads: 33
Joined: Dec 2001
that makes sense! are chr$ 13 and 10 for a carrige return? ill try it out later when i get back to my computer... 8)
Posts: 6,419
Threads: 74
Joined: Mar 2002
You can use the constant VBCRLF:
Code:
text1.text = text1.text + VBCRLF + MoreText
Also I would suggest you to use the list box instead:
Code:
list1.addItem MoreText
Posts: 838
Threads: 17
Joined: Jan 2002
You'll have to set the text's MultiLine proberty to 'true' or you won't be able to have multiple lines.
Also when adding strings together it's & not +
And, you can also use vbNewline
Code:
for i=1 to last
Text1.Text=Text1.Text & name(i) &vbNewline
Next
Hopes it'll help
url=http://www.copy-pasta.com]CopyPasta[/url] -
FilePasta
Posts: 1,752
Threads: 21
Joined: Jun 2002
+ works
Posts: 3,279
Threads: 170
Joined: Nov 2003
A more effective way of doing this is by using the Sel properties. Set SelStart to Len(Text1.Text), then SelText = whatever_text_you're_adding. And yeah, don't forget to set MultiLine to True.
By using the Sel properties, you won't get any flickering in the textbox, and it appears SO much cleaner.
I'd knock on wood, but my desk is particle board.
Posts: 838
Threads: 17
Joined: Jan 2002
Plasma: Yeah, you're right. I don't why I have in 5 years thought that it wouldn't... strange
Adosorkens method is better, as it will scroll the textbox automatically to show the newsest content.
url=http://www.copy-pasta.com]CopyPasta[/url] -
FilePasta
Posts: 142
Threads: 33
Joined: Dec 2001
I got it to work. i used a list box, thanx nath.
Now im probally getting ahead of myself, only having vb for 2 days and all, but i want to put a OK button under the list and when the have it return what ever the user has selected.
Posts: 6,419
Threads: 74
Joined: Mar 2002
Use the list method.
Imagine that you have a listbox filled with info called "list1".
You have a textbox as well to show what the user had selected, called "text1".
You have also a button, called "command1".
Well, all you have to do is add code to the Command1_Click method. This can done easily double-clicking on the button when you are in design mode.
The add this simple code:
Code:
text1.text = list1.list(list1.listcount)
This is easy to follow if you think in the list like a TYPE structure. It contains a string array called "list". You are just accessing it. list1.listcount is the selected item, so you are accessing the data in teh string array called "list" which is in the selected item.
VB is really a piece of cake.