473,804 Members | 3,559 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detect Word Wrap character

I have a VB app that has a richtextbox with the word wrap set to true. I need
to be able to output the text to a text file, but it just puts the text in
the file as one long line.

How do i replace word wrap (i.e. soft returns) with carriage returns?
Nov 23 '05 #1
10 4082
"Jonathan Smith" <Jo***********@ discussions.mic rosoft.com> schrieb:
I have a VB app that has a richtextbox with the word wrap set to true. I
need
to be able to output the text to a text file, but it just puts the text in
the file as one long line.

How do i replace word wrap (i.e. soft returns) with carriage returns?


A VB6 sample for the textbox control can be found here:

<URL:http://www.activevb.de/tipps/vb6tipps/tipp0098.html>

I assume that this technique can be applied to the richtextbox control too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #2
Unfortunately i do not know any german, so i am not exactly sure what that
code is.

At a very simple level, i need to know what Chr() value the wordwrap
character is (e.g. in the same way that carriage return is Chr(13) )

"Herfried K. Wagner [MVP]" wrote:
"Jonathan Smith" <Jo***********@ discussions.mic rosoft.com> schrieb:
I have a VB app that has a richtextbox with the word wrap set to true. I
need
to be able to output the text to a text file, but it just puts the text in
the file as one long line.

How do i replace word wrap (i.e. soft returns) with carriage returns?


A VB6 sample for the textbox control can be found here:

<URL:http://www.activevb.de/tipps/vb6tipps/tipp0098.html>

I assume that this technique can be applied to the richtextbox control too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #3
Jonathan,

I don't know any Madarin, however if that page was written in Madarin, than
at least I would understand the code.

In German is written that any responsibility of the use of the code is at
the user himself for the rest.

Than there is this.
' Steuerelement: Listen-Steuerelement "List1"
Control Listbox is List1

' Steuerelement: Schaltfläche "Command1"
Control button is Command1

' Steuerelement: Textfeld "Text1"

Control textbox is text1

' Steuerelement: Beschriftungsfe ld "Label1"
Control label is Label1.

In my opinion would any developper be able to understand this

In the code is not one word German.

Just my thought,

Cor
Nov 23 '05 #4
Having looked at the link again again, i can honestly say that it does not
address my problem at all.

I need to be able to replace wordwrap control chars with carriage returns.

"Cor Ligthert [MVP]" wrote:
Jonathan,

I don't know any Madarin, however if that page was written in Madarin, than
at least I would understand the code.

In German is written that any responsibility of the use of the code is at
the user himself for the rest.

Than there is this.
' Steuerelement: Listen-Steuerelement "List1"
Control Listbox is List1

' Steuerelement: Schaltfläche "Command1"
Control button is Command1

' Steuerelement: Textfeld "Text1"

Control textbox is text1

' Steuerelement: Beschriftungsfe ld "Label1"
Control label is Label1.

In my opinion would any developper be able to understand this

In the code is not one word German.

Just my thought,

Cor

Nov 23 '05 #5
Hi,

Take a richtextboxes lines property.

http://msdn.microsoft.com/library/de...linestopic.asp

Ken
-----------------
"Jonathan Smith" <Jo***********@ discussions.mic rosoft.com> wrote in message
news:46******** *************** ***********@mic rosoft.com...
I have a VB app that has a richtextbox with the word wrap set to true. I
need
to be able to output the text to a text file, but it just puts the text in
the file as one long line.

How do i replace word wrap (i.e. soft returns) with carriage returns?

Nov 23 '05 #6
Addendum:

The code below (quick and dirty) works pretty well here:

\\\
Private Overloads Declare Auto Function SendMessage Lib "user32" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As String _
) As Int32

Private Overloads Declare Auto Function SendMessage Lib "user32" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32

Private Const EM_GETLINE As Int32 = &HC4
Private Const EM_GETLINECOUNT As Int32 = &HBA
Private Const MAX_CHAR_PER_LI NE As Int32 = &H100
Private Const EM_LINELENGTH As Int32 = &HC1
Private Const EM_LINEINDEX As Int32 = &HBB

Private Function GetLine( _
ByVal Text As TextBoxBase, _
ByVal Line As Integer _
) As String
Dim dwLineStart As Int32 = _
SendMessage(Tex t.Handle, EM_LINEINDEX, Line, 0)
Dim dwLineLen As Integer = _
SendMessage(Tex t.Handle, EM_LINELENGTH, dwLineStart, 0)
Dim Buff As String = _
Chr(dwLineLen And &HFF) & _
Chr(dwLineLen / &H100) & _
Space(dwLineLen )
Dim dwLen As Int32 = _
SendMessage(Tex t.Handle, EM_GETLINE, Line, Buff)
GetLine = Strings.Left(Bu ff, dwLen)
End Function

Private Sub Button2_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button2.Click
Dim Max As Int32
Max = _
SendMessage( _
Me.RichTextBox1 .Handle, EM_GETLINECOUNT , 0, 0 _
) - 1
Me.ListBox1.Ite ms.Clear()
For i As Integer = 0 To Max
Me.ListBox1.Ite ms.Add(GetLine( Me.RichTextBox1 , i))
Next i
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 23 '05 #7
"Ken Tucker [MVP]" <vb***@bellsout h.net> schrieb:
Take a richtextboxes lines property.


The 'Lines' property will ony return the lines separated by new line
character sequences.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #8
Although that code copies the text, it does not maintain any formatting, like
red text, bold text etc..

"Herfried K. Wagner [MVP]" wrote:
Addendum:

The code below (quick and dirty) works pretty well here:

\\\
Private Overloads Declare Auto Function SendMessage Lib "user32" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As String _
) As Int32

Private Overloads Declare Auto Function SendMessage Lib "user32" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32

Private Const EM_GETLINE As Int32 = &HC4
Private Const EM_GETLINECOUNT As Int32 = &HBA
Private Const MAX_CHAR_PER_LI NE As Int32 = &H100
Private Const EM_LINELENGTH As Int32 = &HC1
Private Const EM_LINEINDEX As Int32 = &HBB

Private Function GetLine( _
ByVal Text As TextBoxBase, _
ByVal Line As Integer _
) As String
Dim dwLineStart As Int32 = _
SendMessage(Tex t.Handle, EM_LINEINDEX, Line, 0)
Dim dwLineLen As Integer = _
SendMessage(Tex t.Handle, EM_LINELENGTH, dwLineStart, 0)
Dim Buff As String = _
Chr(dwLineLen And &HFF) & _
Chr(dwLineLen / &H100) & _
Space(dwLineLen )
Dim dwLen As Int32 = _
SendMessage(Tex t.Handle, EM_GETLINE, Line, Buff)
GetLine = Strings.Left(Bu ff, dwLen)
End Function

Private Sub Button2_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button2.Click
Dim Max As Int32
Max = _
SendMessage( _
Me.RichTextBox1 .Handle, EM_GETLINECOUNT , 0, 0 _
) - 1
Me.ListBox1.Ite ms.Clear()
For i As Integer = 0 To Max
Me.ListBox1.Ite ms.Add(GetLine( Me.RichTextBox1 , i))
Next i
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #9
If i use the EM_GETLINES call, how do i copy the richtext formatting aswell???
Nov 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4322
by: TXSherry | last post by:
Hi, I cannot seem to wrap my brain around preg_replace. Though I've read the help file backwords and forwards. :/ Hoping someone can give me a solution here. Problem: Given string 'str' which may contain new lines and will contain html code, IN this string any "words" that begin with an underscore I want to replace with a given word. A word here being a group of chars preceded by a space or null (start of line) and closed by a...
8
3141
by: news.pandora.be | last post by:
I want to display a string in a table but when a word in the string is longer then 40 letters it won't wrap. Does anyone know how I can fix this ? Thanx Wannes
11
5610
by: yawnmoth | last post by:
word wrapping normally treats some spaces as line feeds, if there hasn't been a line feed for quite a while. so while a string with eighty consecutive a's might not word wrap, a space placed squarely in the middle of that string will sorta word wrap. so why doesn't it seem to work with !'s? here's a page that demonstrates how !'s don't seem to word wrap: http://www.geocities.com/terra1024/wordwrap.htm here's a page that shows how...
11
6084
by: name | last post by:
Here is a first attempt at a line/word wrapping utility. Seems to work okay, but lacks some checking stuff, etc. --------------------------------------------------------- #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h>
10
2339
by: Douglas G | last post by:
I've tried various ideas on this problem, but I don't see word wrapping. Can you point out what is wrong? It's a K&R exercise, and I'm still new to programming. Other pointers would be helpful too. #include "header.h" /* does the wordwrapping */ void fold(char buffer, int len) {
10
23325
by: Jeff B. | last post by:
Has anyone come across a decent algorithm for implementing word wrap features in .net printing? I have a small component that uses basic printing techniques (i.e. e.Graphics.DrawString in a PrintPage event of a PrintDocument object) to send some formatted text to the printer. However, if the lines are too long they run off the page rather than wrapping around. I'm sure I can spend the time and come up with a word wrapping algorithm but...
2
65002
by: Yeah | last post by:
Hi, all! I have a question. I am designing a listing similar to a phone book in HTML. Each listing has periods following it, but they must extend to the end of the table cell, and not wrap. Is there any way to prevent the text from 1) wrapping within the table cell and 2) causing the table cell to expand? In other words, the filler periods must flow past the right boundary of the cell (but not be seen). Similar to:
10
72706
by: Lorenzo Thurman | last post by:
I have a table cell that I want to wrap text inside of. I've tried both hard and soft wrap, but Firefox refuses to obey. IE 6&7 handle the wrap just fine. Does anyone know how I can fix this?
5
2494
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I have a project to take a MS Word doc and reformat the text into text files that are built into my App. The only issue I have is some time there are some characters in MS Word that are not printable when viewed in Notepad. I usually catch by looking at the text in my App. Usually the problem is an extra long hyphen --
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2983
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.