Re: Line Formatting

  • From: "RicksPlace" <ofbgmail@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 7 May 2010 09:26:20 -0400

You don't want to mess with the ascii codes. Use the built-in codes. Here is some code where I am formatting a TextBox in VB.net.

MetrixDisplayContent = _

Space(5) _

& "TICKER: " _

& DirectCast( lbReportIndex.SelectedItem, DataRowView) _

("Ticker").ToString() _

& vbCrLf _

& Space(5) _

& DirectCast( lbReportIndex.SelectedItem, DataRowView) _

("Name").ToString() _

& vbCrLf _

& Space(5) _

Now, Above you can see the Vb.net statement that causes a line feed and carage return, likely what you want. So, if you want to check for 20 characters in a string and then add a line feed you can do it in many ways. You can iterate, use a for next loop or something, counting characters and moving each into a new string field. When you get to 20 add the carriage return literal as you see above and then clear the substring for the next line. As you fill each line add it into your textbox. Another way would be to use the SubString method and pick off a substring of 20 characters at a time by just indexing the starting index of the method and then adding the substring into your textbox. These are the 2 easiest ways I can think of of doing what you want. If you are creating the initial document you could just add a seperator like a colon or some other character you do not expect to use in the document as a line seperator after each 20 characters you type but that would be hard on you when typing it up. My code is pretty old, perhaps 5 years old so there might be a newer statement than the vbCrLf statement but it works fine in all my VB.net apps.
Rick USA



----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Cc: "Darko Pogačić" <darko.pogacic@xxxxxxxxx>
Sent: Friday, May 07, 2010 7:26 AM
Subject: Re: Line Formatting


A Line feed is VbLf or Chr(10), a carriage return is VbCr or Chr(13), a form feed is VbFf or Chr(12), a tab is VbTab or Chr(5), and a carriage return/line feed sequence is VbCrLf or Chr(13) & Chr(10).

Jamal


On 5/7/2010 4:55 AM, Darko Pogačić wrote:


You can use vbCrLf constant, but I am not sure which ascii value
represents line by vbCrLf constant, but I am using chr() function, and
representing ascii value 13, its ascii symbol for new line recognized by
microsoft Word.

Also ascii 10 gives a new lin, but I am not sure wich ascii symbol is
for new line given by vbCrLf constant.

* From: * programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] *On Behalf Of *Bryan Schulz
*Sent:* Friday, May 07, 2010 3:32 AM
*To:* programmingblind@xxxxxxxxxxxxx
*Subject:* Re: Line Formatting

hi,

are people using this now instead of vbcrlf?

Bryan Schulz

    ----- Original Message -----

    * From: * Celia Rodriguez <mailto:celia-rodriguez@xxxxxxxxxxxxx>

    * To: * programmingblind@xxxxxxxxxxxxx
    <mailto:programmingblind@xxxxxxxxxxxxx>

    * Sent: * Wednesday, May 05, 2010 10:53 PM

    * Subject: * RE: Line Formatting

    Hi,

    I think this might help.

    TextBox.Text += your string + "\r\n" ;

    The "\r\n" will give you a new line.

    Hope it helps.

    Celia

    * From: * programmingblind-bounce@xxxxxxxxxxxxx
    <mailto:programmingblind-bounce@xxxxxxxxxxxxx>
    [mailto:programmingblind-bounce@xxxxxxxxxxxxx] *On Behalf Of *Darko
    Pogacic
    *Sent:* Tuesday, May 04, 2010 11:41 AM
    *To:* programmingblind@xxxxxxxxxxxxx
    <mailto:programmingblind@xxxxxxxxxxxxx>
    *Subject:* Line Formatting

    Hi there!

    I am interesting how to make Visual Basic code to make a new line
    after a number of characters (EG:5).

    I have a RichTextBox control, and text inside.

    I want to make a Visual Basic 6 code, wich o n each 30 characters,
    puts the rest of text into a new line.

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind



__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: