|
-
May 30th, 2000, 09:42 AM
#1
How would I extract 1 line from a rich text box, make some changes to it using a sub that i already wrote, and then put it back where it was with the changes.
-
May 30th, 2000, 05:17 PM
#2
transcendental analytic
1.
Find the line by splitting the text property between crlf's
Then change the item in the splitted array and join them again and put them into the text.
2.
Or jump with instr to the right position, and extract the text with mid, while you have the start and end position stored. Then change the text and use left and mid to connect the left part, the text and the right part of the rtf.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 30th, 2000, 09:04 PM
#3
Could you write some code for it to help me on my way? Thanks...
-
May 30th, 2000, 10:41 PM
#4
transcendental analytic
Ok the the split-join is probably easy, but i don't konw about the performance. I write the other later if you need it instead
Code:
Dim a
a=split(rtfbox.text,vbcrlf)
a(yourlinenumber)=Yourtext
rtfbox.text=Join(a)
If this doesn't work then it's because i use vb5, and i haven't seen how to use split and join functions, but they probably are used like this
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 31st, 2000, 01:17 AM
#5
Actually, the right way to do it is to use APIs to get the line from the RichTextBox or TextBox:
Code:
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 SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long
Private Const EM_GETLINE = &HC4
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1
Private Sub Command1_Click()
Dim strBuffer As String
Dim lngLineLength As Long
Dim lngIndex As Long
'Get the Index for the first line
'Third parameter in the function specifies the line number (zero based)
lngIndex = SendMessage(RichTextBox1.hwnd, EM_LINEINDEX, 0, 0)
'Get the length of the line
lngLineLength = SendMessage(RichTextBox1.hwnd, EM_LINELENGTH, lngIndex, 0)
'Prepare buffer
strBuffer = Space(lngLineLength)
'Get the line from RichTextBox
Call SendMessageString(RichTextBox1.hwnd, EM_GETLINE, i, ByVal strBuffer)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|