?
Solved

textbox problem

Posted on 2000-04-06
7
Medium Priority
?
221 Views
Last Modified: 2010-05-02
i need to be able to get a line from one multiline textbox and place that line into a single line textbox then delete the original line from the multiline textbox. im looking for simple code something that could be easly understood
0
Comment
Question by:justin05
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2690874
is it a particular line in the multiline textbox or will it be some random line??
0
 
LVL 14

Accepted Solution

by:
waty earned 200 total points
ID: 2691040
' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 18/05/99
' * Time             : 13:05
' **********************************************************************
' * Comments         : Get a particular line in a textbox
' *
' *
' **********************************************************************

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

Public Const EM_GETLINE = &HC4

Public Function GetLine(txtBox As TextBox, LineIndex As Long) As String
   Dim bBuffer()  As Byte   'the byte array
   Dim lngLength  As Long   'the max length of the line
   Dim sRetVal    As String 'the text to return

   'check to see if the LineIndex value is valid
   If LineIndex >= LineCount(txtBox) Then
      'call the LineCount function shown above
      Exit Function 'bale out
   End If

   'get the length of the line
   lngLength = LineLen(txtBox, GetCharFromLine(txtBox, LineIndex))
   'check that there is any text on the line
   If lngLength < 1 Then
      Exit Function
   End If

   'ReDim the byte array
   ReDim bBuffer(lngLength)

   'Save the length in the first word of the array
   bBuffer(0) = lngLength And 255
   bBuffer(1) = lngLength  256

   'Send the message
   SendMessage txtBox.hWnd, EM_GETLINE, LineIndex, bBuffer(0)

   'Finally convert the byte array into a string and return it
   sRetVal = Left$(StrConv(bBuffer, vbUnicode), lngLength)
   GetLine = sRetVal
End Function

0
 
LVL 20

Expert Comment

by:hes
ID: 2691049
Private Sub text1_DblClick()
Text2.Text = Text1.SelText
Text1.SelText = ""
End Sub
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 28

Expert Comment

by:AzraSound
ID: 2691060
hes, that wont highlight the entire line
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2691087
My version:

Option Explicit
Const EM_LINELENGTH = &HC1
Const EM_LINEFROMCHAR = &HC9
Const EM_LINEINDEX = &HBB

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 Sub Command1_Click()

    Dim lChar As Long, lLine As Long, lLen As Long
    Dim lLineIndex As Long
   
    With txtMulti 'Multiline textbox
    lChar = .SelStart
    'Get the absolute line number
    lLine = SendMessage(.hwnd, EM_LINEFROMCHAR, lChar, 0)
    'Get the char pos of beginning of line
    lLineIndex = SendMessage(.hwnd, EM_LINEINDEX, lLine, 0)
    'Get the length of the line
    lLen = SendMessage(.hwnd, EM_LINELENGTH, lChar, 0)
    .SelStart = lLineIndex
    .SelLength = lLen
    'Copy over to the other textbox
    txtLine.Text = Trim(.SelText)
    'Clear the text
    .SelText = ""
    End With
End Sub
0
 

Author Comment

by:justin05
ID: 2693478
this code did not answer my  but i found the answer i was looking for thanks for the help though i did this very simply by doing the following

teststring = Text1
For scan = 1 To Len(teststring)
splited = Mid(teststring, scan, 1)
If splited = Chr(10) Then
    endline = scan
    scan = Len(teststring)
End If
Next scan
textedit = Left(teststring, endline)
strfind = textedit.Text
intlen = Len(strfind)
Text1.SelStart = 0
Text1.SelLength = intlen
Text1.SelText = ""


as you can see this is very simple and it worked for what i was doing thank you all for your help
0
 

Expert Comment

by:yuvaraj
ID: 2693482
You need to use the Cut, Copy & Paste options.

First you get the current cursor position ie the start of the blocked text or the start of the line.

Then from there you use the mid function to cut the portion and add this to the textbox.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question