Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


Click here to copy the following block
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
Const EM_FMTLINES = &HC8

' Return an array with all the lines in the control.
' If the second optional argument is True, the hard CR-LFs are preserved
' (hard CR-LFs are those inserted by the user, soft CRLFs are those inserted
' automatically to wrap long lines)

Function TextBoxGetLines(tb As TextBox, Optional KeepHardLineBreaks As Boolean) _
  As String()
  Dim result() As String
  Dim i As Long

  ' Activate soft line breaks. A soft line break is marked by the
  ' CR-Cr-LF sequence.
  SendMessage tb.hwnd, EM_FMTLINES, True, ByVal 0&

  ' Retrieve all the lines in one operation and split results.
  ' This operation will leave trailing CR character for soft line breaks only.
  result() = Split(tb.Text, vbCrLf)

  ' We need a loop to trim the trailing CR character. If the second
  ' argument is true, we need to manually add a CR-LF pair to all
  ' the lines that don't contain such trailing CR char.
  For i = 0 To UBound(result)
    If Right$(result(i), 1) = vbCr Then
      result(i) = Left$(result(i), Len(result(i)) - 1)
    ElseIf KeepHardLineBreaks Then
      result(i) = result(i) & vbCrLf
    End If
  Next

  ' Deactivate soft line breaks.
  SendMessage tb.hwnd, EM_FMTLINES, False, ByVal 0&

  TextBoxGetLines = result()
End Function


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.