Hi: Well I am not sure about the old vb 6 code methods but I tried to code up a simple block to just loop through the RTF TextBox and create a Document with lines of 25 characters with a line feed and carige return at the end of each line. I did not test out this code nor even check it for syntax errors since I am running VB 2008 but you can do that by printing out the lines and making sure they are correct. Here is some code I would start with, test it a couple of RTF Documents and make sure it is working. My indices are usually 0 based so it might be diferent but the following is where I would start to keep it simple. What I want it to do is to loop until all the contents of the RTF TextBox have been read. The ndx variable is bumped by 25 characters on each iteration of the loop. The last time it will be larger than the length of the RTF TextBox and the loop will end. Every time the loop is executed we want to pick off the next 25 characters from the Rich Text Box, add them into a temporary line, add the VbCrlf or whatever line end you want and then add that formatted line into the new formatted document.
Private Sub mnuFormatBraille_Click() Dim FormattedDocument As String = "" Dim ndx As Integer = 1 While ndx < Len(docform.rtfText.Text) Dim FormattedLine As String = _ Mid$(docform.rtfText.Text,ndx,25) FormattedDocument = FormattedDocument & FormattedLine & vbCrLf ndx = ndx + 25 End While End SubYou need to check the syntax, the start of ndx, should it be 1 or 0, and make sure that adding 25 to it will pick up the next desired character from the RTF TextBox document but this might give you an idea of how I might attack this piece of code in a VB orientated app.
Rick USA -----Original Message----- From:----- Original Message ----- From: "Darko Pogačić" <darko.pogacic@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx> Sent: Friday, May 07, 2010 9:54 AM Subject: RE: Line Formatting Thanks! I've tryed to find idea, and my code loocks as: Private Sub mnuFormatBraille_Click() Dim I As Long, characters As String, numchar As Long, linnum As Long Numchar = 1 Linnum = 0 Characters = "" For I = 1 To Len(docform.rtfText.Text) If I < Len(docform.rtfText.Text) Then Characters = characters & Mid$(docform.rtfText.Text,numchar,25) & vbCr Numchar = numchar + 25 Linnum = linnum + 1 If linnum = 30 Then Characters = characters & vbLf End If Linnum = 0 Linnum = linnum + 1 End If Next I Docform.rtfText.Text = characters End Sub -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of RicksPlace Sent: Friday, May 07, 2010 3:26 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: Line Formatting 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 __________ 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