Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

carriage return/line feed in multiple-line textbox 1

Status
Not open for further replies.

hansu

Programmer
Mar 12, 2002
89
I want to use the text entered by the user into a multiple-line textbox to print it out with the printer object. I realise that the carriage return and line feed characters are not inserted in the textstring where the textbox breaks the lines.
Can anyone tell me how to insert these characters into the textstring. I want to print out the text exactly how it appeared in the textbox.

Thank's for your assitance.
Hansu
 
[tt]
Option Explicit
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_GETLINE = &HC4
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function strSendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long


Private Sub Command1_Click()
MsgBox DumpMultiText(Text1)
End Sub

Private Function DumpMultiText(tbSource As TextBox) As String
Dim lp As Long
Dim Maxlines As Long
Dim strBuffer As String
Dim LineLength As Long

Maxlines = SendMessage(tbSource.hwnd, EM_GETLINECOUNT, 0&, 0&)
For lp = 0 To Maxlines - 1
LineLength = SendMessage(tbSource.hwnd, EM_LINELENGTH, SendMessage(tbSource.hwnd, EM_LINEINDEX, lp, 0&), 0&)
strBuffer = Space(LineLength)
strSendMessage tbSource.hwnd, EM_GETLINE, lp, strBuffer
DumpMultiText = DumpMultiText + strBuffer + vbCrLf
Next
End Function
 
Thank you strongm.
That works fine!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top