Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Showing stuff in VB
#1
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...
Reply
#2
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...
Reply
#3
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)
Reply
#4
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
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#5
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
Reply
#6
+ works Tongue
Reply
#7
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.
Reply
#8
Plasma: Yeah, you're right. I don't why I have in 5 years thought that it wouldn't... strange Big Grin

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
Reply
#9
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.
Reply
#10
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.

Wink VB is really a piece of cake.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)