|
-
Jul 4th, 2003, 10:15 AM
#1
Thread Starter
Hyperactive Member
remove using replace function
hi,
I wanna remove a line from a textbox and I use the following code
VB Code:
ln = "e.g Line 3"
Text1 = Replace(Text1, ln, vbnullstring)
I know it wont work but just to make the idea clear to you
what should I pass to the replace parameter so that it removes that line completely 
thanks
-
Jul 4th, 2003, 10:18 AM
#2
Fanatic Member
-
Jul 4th, 2003, 10:24 AM
#3
Thread Starter
Hyperactive Member
it wont remove that line
the multiline property of the textbox is true & if you replace it with "" a blank line will remain there
-
Jul 4th, 2003, 10:29 AM
#4
Lively Member
i don't know how to do it using Replace, but i can do it using the Split command
VB Code:
Dim test As String, remove() As String, line As Integer
test = "remove" & vbCrLf & "the next line!" & vbCrLf & "abcdefghi"
line = 3 ' -> we want to remove line number 3
remove = Split(test, vbCrLf)
For i = 0 To UBound(remove)
If i <> (line - 1) Then ' -> arrays begin with 0, not 1
Text1.Text = Text1.Text & remove(i) & vbCrLf
End If
Next i
maybe this would be good as a backup if you couldn't find out how with the Replace command
Anticipation of death is worse than death itself
-
Jul 4th, 2003, 10:36 AM
#5
Thread Starter
Hyperactive Member
hello Walter
the problem is that I dont know the line number
I just know the text of the line I wanna remove
-
Jul 4th, 2003, 10:42 AM
#6
Lively Member
oh, i see now! i thought you knew the specific line you wanted to remove. this seems to work for me:
VB Code:
Dim test As String
test = "remove" & vbCrLf & "the next line!" & vbCrLf & "abcdefghi"
test = Replace(test, "abcdefghi", "")
test = Mid(test, 1, Len(test) - 2)
Text1.Text = test
Anticipation of death is worse than death itself
-
Jul 4th, 2003, 10:54 AM
#7
Thread Starter
Hyperactive Member
oh! it doesn't work
try this
VB Code:
Dim test As String
test = "remove" & vbCrLf & "the next line!" & vbCrLf & "abcdefghi"
test = Replace(test, "the next line!", "")
test = Mid(test, 1, Len(test) - 2)
Text1.Text = test
-
Jul 4th, 2003, 10:58 AM
#8
Lively Member
i beg your pardon 
you didn't specify whether it was the last line or not. but it works in theory just change it so that it concacenates the rest of the string after it's removed the line
Anticipation of death is worse than death itself
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
|