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? 10 4059
"Jonathan Smith" <Jo***********@discussions.microsoft.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/>
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.microsoft.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/>
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: Beschriftungsfeld "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
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: Beschriftungsfeld "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
Hi,
Take a richtextboxes lines property. http://msdn.microsoft.com/library/de...linestopic.asp
Ken
-----------------
"Jonathan Smith" <Jo***********@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.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?
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_LINE 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(Text.Handle, EM_LINEINDEX, Line, 0)
Dim dwLineLen As Integer = _
SendMessage(Text.Handle, EM_LINELENGTH, dwLineStart, 0)
Dim Buff As String = _
Chr(dwLineLen And &HFF) & _
Chr(dwLineLen / &H100) & _
Space(dwLineLen)
Dim dwLen As Int32 = _
SendMessage(Text.Handle, EM_GETLINE, Line, Buff)
GetLine = Strings.Left(Buff, 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.Items.Clear()
For i As Integer = 0 To Max
Me.ListBox1.Items.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/>
"Ken Tucker [MVP]" <vb***@bellsouth.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/>
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_LINE 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(Text.Handle, EM_LINEINDEX, Line, 0) Dim dwLineLen As Integer = _ SendMessage(Text.Handle, EM_LINELENGTH, dwLineStart, 0) Dim Buff As String = _ Chr(dwLineLen And &HFF) & _ Chr(dwLineLen / &H100) & _ Space(dwLineLen) Dim dwLen As Int32 = _ SendMessage(Text.Handle, EM_GETLINE, Line, Buff) GetLine = Strings.Left(Buff, 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.Items.Clear() For i As Integer = 0 To Max Me.ListBox1.Items.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/>
If i use the EM_GETLINES call, how do i copy the richtext formatting aswell???
"Jonathan Smith" <Jo***********@discussions.microsoft.com> schrieb: Although that code copies the text, it does not maintain any formatting, like red text, bold text etc..
That's true. I feel sorry, but I currently do not know a way to preserve
the formatting.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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'...
|
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
|
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...
|
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>...
|
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...
|
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...
|
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.
...
|
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?
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |