Click to See Complete Forum and Search --> : delete curent line from text box


ma622
August 13th, 2001, 04:32 AM
HI, im trying to do a program that will find the word "****" in the text box and will delete the line that the word is on it.
for example:

the text is:

hello mother****
whats up?

so i want that it will leave only the whats up?

PLZ answer

Cakkie
August 13th, 2001, 05:57 AM
This will remove those dirty words for you ;)
Just place a textbox named text1 on the form, a button called command1, and copy the code into the form. Run, type some stuff, and press the button.

private Sub Command1_Click()

Dim strText as string
Dim iPosFck as Integer
Dim iPosBef as Integer
Dim iPosAft as Integer

strText = Text1.Text

iPosFck = InStr(1, strText, "****", vbTextCompare)

Do Until iPosFck = 0

' locate first CrLf
iPosBef = InStr(1, strText, vbCrLf)

If iPosBef = 0 then
' only one line, so empty the box
strText = ""
ElseIf iPosBef > iPosFck then
' Fck is in the first line
strText = mid(strText, iPosBef + 2)
else

' locate the CrLf just before the Fck
Do Until InStr(iPosBef + 1, strText, vbCrLf) > iPosFck Or InStr(iPosBef + 1, strText, vbCrLf) = 0
iPosBef = InStr(iPosBef + 1, strText, vbCrLf)
Loop

' locate the first CrLf after Fck
iPosAft = InStr(iPosBef + 1, strText, vbCrLf)

If iPosAft = 0 then
' Fck in last line
strText = Left(strText, iPosBef - 1)
else
strText = Left(strText, iPosBef - 1) & mid(strText, iPosAft)
End If

End If

' see if we need to go through it again
iPosFck = InStr(1, strText, "****", vbTextCompare)

Loop

Text1.Text = strText

End Sub




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

d.paulson
August 13th, 2001, 07:57 AM
Another idea maybe to just replace the offending words with another.

Text1 = replace(text1,"badword","goodword")


David Paulson

ma622
August 13th, 2001, 08:43 AM
yeah its good but its not what i want....i want to remove whole line:

for EXAMPLE my text is:

**** u *****...
whats up?

so i want that it will be :
whats up?

10X

ma622
August 13th, 2001, 08:55 AM
oooooops.....!!!!! sorry its good......
now...i want to fix it...
want that it will delete all the bad words except the first one...

for example:

hey mother ****er?
whats up?
u big ****....

i want that it will be:

hey mother ****er?
whats up?

ma622
August 13th, 2001, 09:06 AM
lol......and there is the last one:

i wanna do a prog that will find words that r repeated..and will delete the hole line that the word is on it:

for example:

the ip is: 127.0.0.1
the ip is: 127.0.0.3
the ip is: 127.0.0.1
the ip is: 127.1.0.2

so i want that it will be:
the ip is: 127.0.0.3
the ip is: 127.0.0.2


10X

ma622
August 13th, 2001, 09:12 AM
listen the code is good but try this:

~~ Love is a mother****er ~~

Walking in twilight near my open grave
To swallow my lust and grace
And one more death waits in my bed
To take my innocence
This nothingness these people call the world,
That extincted kiss upon my lips
When dreamers deal with undertakers
I only scream when angels sleep

Love is just another mother****er.
Love is just another mother****er.

Like a spider trapped in its own web
Darkness weaves all open sears
To wallow in, forever in, forever bond
What's that liqueur you call tears?

Love is just another mother****er.
Love is just another mother****er.

Touch me, night
Stroke and bite
Open the gates to hell
One way
Love me, pain
Love, in vain
Open the gates to hell
One way
Touch me, night
Stroke and bite
Open the gates to hell
One way
Love me, pain
Love, in vain
Open the gates to hell
One way
To hell one way to hell one way to hell...

Oh, love, you're just another mother****er.
Just another mother****er.

and try to remove the "ker"
and this is will not remove all the "ker"s

gena
August 13th, 2001, 09:23 AM
Hi!
Just 5 min before I've found this. Think it's worth to try:
http://www.developersdomain.com/vb/codedownloads/textboxfeatures.zip
Undocumented features of textbox, actually treated as Window and as such - target for Windows messages.

Regards,
Gennady

Cakkie
August 13th, 2001, 09:29 AM
Ok, i'm not going to ask what exactly you are going to do with the code, but anyway...

I tried the text with the code i gave you, and it gave me this:


Walking in twilight near my open grave
To swallow my lust and grace
And one more death waits in my bed
To take my innocence
This nothingness these people call the world,
That extincted kiss upon my lips
I only scream when angels sleep


Like a spider trapped in its own web
Darkness weaves all open sears
To wallow in, forever in, forever bond
What's that liqueur you call tears?


Touch me, night
Stroke and bite
Open the gates to hell
One way
Love me, pain
Love, in vain
Open the gates to hell
One way
Touch me, night
Stroke and bite
Open the gates to hell
One way
Love me, pain
Love, in vain
Open the gates to hell
One way
To hell one way to hell one way to hell...


unless my eyes decieve me, there are no mer ker's in there.

For the other problems, the first one is kinda a tricky one, cause you will always have fck in your text. One thing you can do is to keep track of the position the line was (iposBef to iPosAft) and the line itself of course. Then after processingm insert the line again.

The second problem I would take a totally different approach. I would ibnsert the data in a database, and then do a selec statement on it, giving only those not reoccuring.

SELECT LineText FROM tblLines WHERE COUNT(LineText) = 1 GROUP BY LineText




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

ma622
August 13th, 2001, 12:18 PM
yo man, 10X but here is my last fix:

i want to do a prog that will delete all the words that from the text that r repeated.

for example:

my test is:

212.150.90.196
212.150.90.197
212.150.90.198
212.150.90.195

so i want the program to delete the same lines and leave only
212.150.90.197
212.150.90.198

u c, i want the program to delete her self all the repeated words

and iPosFck = InStr(1, strText, "text", vbTextCompare)
not letting me to do it: i want the program to detect herself the words that r repeated.....and the delete both of themm



10X man..