Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
Making new line for a String in Visual basic or VB6

 
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum
Author Message
Belal
User
User


Joined: 08 Mar 2004
Posts: 84
Location: Dhaka, Bangladesh

Post Post subject: Making new line for a String in Visual basic or VB6 Reply with quote

Hi dk,

i m getting some values frm a database table and making them
a single stirng. there's no prob. but i like to show each new field
(e.g. 'name' in a line, 'address' in a line etc.) in a new line and
then show in a text field control (while property multiline is 'true').
some other programming language does it with '\n'. i need to know how
can i do it in vb? hope u manage some time to answer it, though i know
u r busy with ur exam preparation.
_________________
we've lot of things to think abt curr probs
so, i don't have time to think abt religion or wonder of sceice .......... how ppl can waste their time like this?
Sun May 30, 04 8:06 am
Back to top
Belal View user's profile Send private message Yahoo Messenger MSN Messenger
dude
Power User
Power User


Joined: 10 Mar 2004
Posts: 376
Location: Savar, Dhaka

Post Post subject: Reply with quote

Hi Belal,

I am not good at all in Visual Basic. But I found this out for you.

In VB, for a text box, its attributes can be changed only in one of the two ways, by setting the scrollbar and multiline properties. And this is done only from the design views.

Setting MultiLine to True lets a text box to accept or display multiple lines of text at the VB application run time. And a multiple-line enabled text box automatically manages word wrap as long as there is no horizontal scroll bar. The ScrollBars property is set to 0-None by default.

Automatic word wrap saves the user the trouble of inserting line breaks at the end of lines. When a line of text is longer than what can be displayed on a line, the text box wraps the text to the next line.

Now for what you want to do, line breaks cannot be entered in the Properties window at design time. Within a procedure, you will have to create the line break manually by using ANSI Chr(10) for LF and Chr(13) for CR. But it seems like this is not working for you. Did you try? If it is not working then I think, you are using Visual Basic 6.0. Here is another way.

You can also use the constant vbCrLf to insert a carriage return/linefeed combination. In the example below, the following event procedure puts two lines of text into a multiple-line text box (Text1) when the form is loaded:

Sub Form_Load ()
Text1.Text = "Here are two lines" _
& vbCrLf & "in a text box"
End Sub


vbCrLf also works on systems where a NewLine is not CrLf.

There are other methods also. I do not know if they work on all versions of VB and which one is right for what. Like:
'Environment.NewLine', 'ControlChars.NewLine',
'vbNewLine'

I think oneof them will work for you.
Mon May 31, 04 9:48 am
Back to top
dude View user's profile Send private message Visit poster's website
dinangkur
Super Moderator
Super Moderator


Joined: 24 Mar 2004
Posts: 491
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Dude did say everything. Wonderful explanation.

-DK.
_________________
...we too are stardust...
Mon May 31, 04 12:12 pm
Back to top
dinangkur View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Belal
User
User


Joined: 08 Mar 2004
Posts: 84
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

thanks dude and dk.

dude's solution is working. dude, u don't seems u r poor in vb. u can give a try, hopefully win vb.
_________________
we've lot of things to think abt curr probs
so, i don't have time to think abt religion or wonder of sceice .......... how ppl can waste their time like this?
Tue Jun 01, 04 12:38 pm
Back to top
Belal View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group