-
Sep 21st, 2002, 08:22 PM
#1
[RESOLVED] Detect words in a listbox (Resolved)
Hi,
I am trying to detect words that are in a listbox by typing a word in a textbox then click if the word is in the box.
VB Code:
Private Sub Command1_Click()
For b = 0 To frmSetup.Lstblock.ListCount
If Text1.Text = frmSetup.Lstblock.List(b) Then
MsgBox ("Word is not allowed")
Else
If Not Text1.Text = Text1.Text & frmSetup.Lstblock.List(b) Then
Exit Sub
End If
End If
Next b
frmSetup.Show
End Sub
This code works only when I type in the word that is the first word listed in the listbox. How can I make in so it checks for all the wors typed into the listbox?
Last edited by Nightwalker83; Oct 18th, 2002 at 06:13 PM.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 21st, 2002, 08:31 PM
#2
-= B u g S l a y e r =-
you can either use InStr or the Like operator :
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If UCase(List1.List(i)) Like UCase("*" & Text1.Text & "*") Then List1.ListIndex = i
Next i
End Sub
Private Sub Form_Load()
With List1
.Clear
.AddItem "CPU"
.AddItem "RAM"
.AddItem "ROM"
.AddItem "Cache"
.AddItem "Motherboard"
.AddItem "Hard Disk"
.AddItem "Floppy Disk"
End With
End Sub
-
Sep 21st, 2002, 09:51 PM
#3
^:^...ANGEL...^:^
Re: Detect words in a listbox
Originally posted by Nightwalker83
Hi,
I am trying to detect words that are in a listbox by typing a word in a textbox then click if the word is in the box.
VB Code:
Private Sub Command1_Click()
For b = 0 To frmSetup.Lstblock.ListCount
If Text1.Text = frmSetup.Lstblock.List(b) Then
MsgBox ("Word is not allowed")
Else
If Not Text1.Text = Text1.Text & frmSetup.Lstblock.List(b) Then
Exit Sub
End If
End If
Next b
frmSetup.Show
End Sub
This code works only when I type in the word that is the first word listed in the listbox. How can I make in so it checks for all the wors typed into the listbox?
u can use API..
VB Code:
'This project needs a ListBox, named List1 and a TextBox, named Text1
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Private Sub Form_Load()
'KPD-Team 1998
'URL: [url]http://www.allapi.net/[/url]
'E-Mail: [email]KPDTeam@Allapi.net[/email]
'Add some items to the listbox
With List1
.AddItem "Computer"
.AddItem "Screen"
.AddItem "Modem"
.AddItem "Printer"
.AddItem "Scanner"
.AddItem "Sound Blaster"
.AddItem "Keyboard"
.AddItem "CD-Rom"
.AddItem "Mouse"
End With
End Sub
Private Sub Text1_Change()
'Retrieve the item's listindex
List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(Text1.Text))
End Sub
-
Sep 21st, 2002, 09:51 PM
#4
^:^...ANGEL...^:^
Re: Detect words in a listbox
Originally posted by Nightwalker83
Hi,
I am trying to detect words that are in a listbox by typing a word in a textbox then click if the word is in the box.
VB Code:
Private Sub Command1_Click()
For b = 0 To frmSetup.Lstblock.ListCount
If Text1.Text = frmSetup.Lstblock.List(b) Then
MsgBox ("Word is not allowed")
Else
If Not Text1.Text = Text1.Text & frmSetup.Lstblock.List(b) Then
Exit Sub
End If
End If
Next b
frmSetup.Show
End Sub
This code works only when I type in the word that is the first word listed in the listbox. How can I make in so it checks for all the wors typed into the listbox?
u can use API..
VB Code:
'This project needs a ListBox, named List1 and a TextBox, named Text1
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Private Sub Form_Load()
'KPD-Team 1998
'URL: [url]http://www.allapi.net/[/url]
'E-Mail: [email]KPDTeam@Allapi.net[/email]
'Add some items to the listbox
With List1
.AddItem "Computer"
.AddItem "Screen"
.AddItem "Modem"
.AddItem "Printer"
.AddItem "Scanner"
.AddItem "Sound Blaster"
.AddItem "Keyboard"
.AddItem "CD-Rom"
.AddItem "Mouse"
End With
End Sub
Private Sub Text1_Change()
'Retrieve the item's listindex
List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(Text1.Text))
End Sub
Cheers...
-
Sep 22nd, 2002, 01:26 AM
#5
Originally posted by peet
you can either use InStr or the Like operator :
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If UCase(List1.List(i)) Like UCase("*" & Text1.Text & "*") Then List1.ListIndex = i
Next i
End Sub
Private Sub Form_Load()
With List1
.Clear
.AddItem "CPU"
.AddItem "RAM"
.AddItem "ROM"
.AddItem "Cache"
.AddItem "Motherboard"
.AddItem "Hard Disk"
.AddItem "Floppy Disk"
End With
End Sub
Thanx it works but it shows the msgbox I am using even if you just enter the letters that are in the listbox. How can I stop this so you can enter those letters without the msgbox appearing? I also want to know how I can stop it from happening when the user empties the textbox?
Below is how I am using the code:
VB Code:
Private Sub txtSay_Change()
Dim i As Integer
For i = 0 To frmSetup.Lstblock.ListCount - 1
If UCase(frmSetup.Lstblock.List(i)) Like UCase("*" & txtSay.Text & "*") Or LCase(frmSetup.Lstblock.List(i)) Like LCase("*" & txtSay.Text & "*") Then
MsgBox ("This word is not allowed")
End If
Next i
End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 22nd, 2002, 02:33 PM
#6
-= B u g S l a y e r =-
Originally posted by Nightwalker83
Thanx it works but it shows the msgbox I am using even if you just enter the letters that are in the listbox. How can I stop this so you can enter those letters without the msgbox appearing? I also want to know how I can stop it from happening when the user empties the textbox?
Below is how I am using the code:
VB Code:
Private Sub txtSay_Change()
Dim i As Integer
For i = 0 To frmSetup.Lstblock.ListCount - 1
If UCase(frmSetup.Lstblock.List(i)) Like UCase("*" & txtSay.Text & "*") Or LCase(frmSetup.Lstblock.List(i)) Like LCase("*" & txtSay.Text & "*") Then
MsgBox ("This word is not allowed")
End If
Next i
End Sub
it all depends on how you want it to work ...
you want the search to be done when the user click a button, hit enter or something else ??
in order to not do a search when the textbox is empty, you have to check the content of the textbox
if txtSay.text = "" then exit sub
-
Sep 22nd, 2002, 10:00 PM
#7
Originally posted by peet
it all depends on how you want it to work ...
you want the search to be done when the user click a button, hit enter or something else ??
in order to not do a search when the textbox is empty, you have to check the content of the textbox
if txtSay.text = "" then exit sub
Peet,
I want the program to tell me if a word that has been banned, if then word has been entered into the textbox. I am trying to make it check when I type in the textbox.
I have changed this code of your by putting "a" instead of "i" but now it wont work.
VB Code:
Dim a As Integer
For a = 0 To frmSetup.Lstblock.ListCount - 1
If txtSay.Text = "" Then
Exit Sub
Else:
If UCase(frmSetup.Lstblock.List(i)) Like UCase("*" & txtSay.Text & "*") Then
MsgBox ("This word is not allowed")
End If
End If
Next a
I actually put public "a" as integer in a module but is of in the form code but it still didn't work.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 23rd, 2002, 02:45 AM
#8
-= B u g S l a y e r =-
Hi again NW,
you have made a couple of mistakes... first you do not use option explicit. I think that would have found the first problem. You use i instead of a in this line
VB Code:
If UCase(frmSetup.Lstblock.List(i)) Like UCase("*" & txtSay.Text & "*") Then
it should have been
VB Code:
If UCase(frmSetup.Lstblock.List(a)) Like UCase("*" & txtSay.Text & "*") Then
I would do something like this:
VB Code:
Private Sub txtSay_Change()
Dim a As Integer
'any data at all ? if not exit
If txtSay.Text = "" Then
Lstblock.ListIndex = -1
Exit Sub
End If
'check to see if there is data in the listbox that matches txtSay
For a = 0 To frmSetup.Lstblock.ListCount - 1
If UCase(frmSetup.Lstblock.List(a)) Like UCase("*" & txtSay.Text & "*") Then
'found one that match current crit.
'select it in the listbox, and then exit the loop
Lstblock.ListIndex = a
Exit For
Else
Lstblock.ListIndex = -1
End If
Next a
End Sub
a msgbox is no good in this case, because of the event you use.
hope this is what you are looking for
-
Sep 23rd, 2002, 02:55 AM
#9
Originally posted by peet
Hi again NW,
you have made a couple of mistakes... first you do not use option explicit. I think that would have found the first problem. You use i instead of a in this line
VB Code:
If UCase(frmSetup.Lstblock.List(i)) Like UCase("*" & txtSay.Text & "*") Then
it should have been
VB Code:
If UCase(frmSetup.Lstblock.List(a)) Like UCase("*" & txtSay.Text & "*") Then
I would do something like this:
VB Code:
Private Sub txtSay_Change()
Dim a As Integer
'any data at all ? if not exit
If txtSay.Text = "" Then
Lstblock.ListIndex = -1
Exit Sub
End If
'check to see if there is data in the listbox that matches txtSay
For a = 0 To frmSetup.Lstblock.ListCount - 1
If UCase(frmSetup.Lstblock.List(a)) Like UCase("*" & txtSay.Text & "*") Then
'found one that match current crit.
'select it in the listbox, and then exit the loop
Lstblock.ListIndex = a
Exit For
Else
Lstblock.ListIndex = -1
End If
Next a
End Sub
a msgbox is no good in this case, because of the event you use.
hope this is what you are looking for
Peet,
I was actually hoping that I could get it so I could enter the whole word before the msgbox appears. Is this possible?
I am only using the msgbox for testing my app.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 23rd, 2002, 03:36 AM
#10
-= B u g S l a y e r =-
how do you know when an entire word is added to the text box?
if you can answer that, Ï think you will find the solution
I would suggest moving the routine from the changeevent to keyupevent and check to see if the keypressed = enterkey. If so, do a search.
or move it to lost focus.
how do you want it to be?
-
Sep 23rd, 2002, 04:25 AM
#11
Originally posted by peet
how do you know when an entire word is added to the text box?
if you can answer that, Ï think you will find the solution
I would suggest moving the routine from the changeevent to keyupevent and check to see if the keypressed = enterkey. If so, do a search.
or move it to lost focus.
how do you want it to be?
I was think about checking a string is that possible? I am really wanting that code to detect the words that are been passed to it from the other chat app.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 23rd, 2002, 04:48 AM
#12
Evening NightWalker,
Can you 'trap' the unwanted word(s) before there loaded
into the TextBox?
-
Sep 24th, 2002, 01:36 AM
#13
Originally posted by Bruce Fox
Evening NightWalker,
Can you 'trap' the unwanted word(s) before there loaded
into the TextBox?
What I am trying to do is something on this forum how if your post has a swear word(s) in it the swear word gets replaced with ****.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 24th, 2002, 03:12 AM
#14
Not NoteMe
How about just doing a relpace on the textbox string with each of the listbox entries once the user is finished typing?
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts.
-
Sep 24th, 2002, 03:14 AM
#15
Originally posted by Nightwalker83
I was think about checking a string is that possible? I am really wanting that code to detect the words that are been passed to it from the other chat app.
Maybe Split the incomming String into and Array at the " " (prior to being placed into a Display TextBox).
eg. arr = Split(sInputBuff, " ")
Then run the arr data against the ListBox, and at a 'match' replace
that array element with "****", then use:
eg. TextBoxDisplay = Join(arr, " ")
Bruce.
-
Sep 24th, 2002, 05:34 AM
#16
Originally posted by Bruce Fox
Maybe Split the incomming String into and Array at the " " (prior to being placed into a Display TextBox).
eg. arr = Split(sInputBuff, " ")
Then run the arr data against the ListBox, and at a 'match' replace
that array element with "****", then use:
eg. TextBoxDisplay = Join(arr, " ")
Bruce.
How would I do this?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 24th, 2002, 06:09 AM
#17
Originally posted by Nightwalker83
How would I do this?
Well.... first; confirm what the incomming text is in. ie is the
chat text received in you app via a String?
Which is then placed into a TextBox?
-
Sep 24th, 2002, 06:37 AM
#18
This is an example of what I mean. Place a ListBox on a Form.
Assume the String Buffer sInputBuff is the incomming Text:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim sInputArr() As String
Dim sInputBuff As String: sInputBuff = "This is a test to see if it works"
Dim i As Integer
Dim x As Integer
'Add some of the unwanted words to a ListBox
With List1
.AddItem "Badword1"
.AddItem "Badword2"
.AddItem "test"
.AddItem "Badword4"
End With
'Split up the String into the Array
If InStr(sInputBuff, " ") Then 'More than 1 word, so split
sInputArr = Split(sInputBuff, " ")
Else
ReDim sInputArr(0) 'Only 1 word, so place it in the Array
sInputArr(0) = sInputBuff
End If
For x = 0 To UBound(sInputArr)
For i = 0 To List1.ListCount - 1
If LCase(List1.List(i)) = LCase(sInputArr(x)) Then sInputArr(x) = "*****"
Next
Next
MsgBox Join(sInputArr) 'Join this in a TextBox
End Sub
-
Sep 24th, 2002, 07:57 PM
#19
Originally posted by Bruce Fox
This is an example of what I mean. Place a ListBox on a Form.
Assume the String Buffer sInputBuff is the incomming Text:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim sInputArr() As String
Dim sInputBuff As String: sInputBuff = "This is a test to see if it works"
Dim i As Integer
Dim x As Integer
'Add some of the unwanted words to a ListBox
With List1
.AddItem "Badword1"
.AddItem "Badword2"
.AddItem "test"
.AddItem "Badword4"
End With
'Split up the String into the Array
If InStr(sInputBuff, " ") Then 'More than 1 word, so split
sInputArr = Split(sInputBuff, " ")
Else
ReDim sInputArr(0) 'Only 1 word, so place it in the Array
sInputArr(0) = sInputBuff
End If
For x = 0 To UBound(sInputArr)
For i = 0 To List1.ListCount - 1
If LCase(List1.List(i)) = LCase(sInputArr(x)) Then sInputArr(x) = "*****"
Next
Next
MsgBox Join(sInputArr) 'Join this in a TextBox
End Sub
I don't know what I am doing wrong this is the code I am using:
VB Code:
Private Sub Messlis_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim sInputArr() As String
Dim sInputBuff As String: sInputBuff = "This is a test to see if it works"
Messlis(intmax).GetData str
'Get the message string
If InStr(1, str, "|MESSAGE|") <> 0 Then
mess = Mid$(str, 10, Len(str))
Dim objFrmMain As New frmMain
txtMess.SelStart = Len(mess)
txtMess.SelText = mess
End If
'check to see if there is data in the listbox that matches the mess string
'Split up the String into the Array
If InStr(sInputBuff, " ") Then 'More than 1 word, so split
sInputArr = Split(sInputBuff, " ")
Else
ReDim sInputArr(0) 'Only 1 word, so place it in the Array
sInputArr(0) = sInputBuff
End If
For X = 0 To UBound(sInputArr)
For a = 0 To frmSetup.Lstblock.ListCount - 1
If UCase(frmSetup.Lstblock.List(a)) = UCase(sInputArr(X)) Then sInputArr(X) = "*****"
Next
Next
txtMess.Text = Join(sInputArr) 'Join this in a TextBox
End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 24th, 2002, 08:06 PM
#20
Whats the error? What line is highlighted?
-
Sep 24th, 2002, 08:09 PM
#21
What does sInputBuffer =?????
its just there by its self!
maybe sInputBuffer should 'mess' (or replace it)
-
Sep 24th, 2002, 11:22 PM
#22
Originally posted by Bruce Fox
What does sInputBuffer =?????
its just there by its self!
maybe sInputBuffer should 'mess' (or replace it)
VB Code:
Dim sInputBuff As String: sInputBuff = mess 'mess being the string that was sent minus the instr part.
Is that right? When I use the code from my previous post:
VB Code:
Dim sInputBuff As String: sInputBuff = "This is a test to see if it works"
The only thing that appears it the other client window after the data is sent is what you put for sIntputBuff that is without the ****.
Last edited by Nightwalker83; Sep 24th, 2002 at 11:29 PM.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 24th, 2002, 11:40 PM
#23
No, No, No
I set sInputBuff to that string to demonstrate how it may work.
You need to place the message text in there!
Does that make sense.
Bruce.
-
Sep 24th, 2002, 11:57 PM
#24
Originally posted by Bruce Fox
No, No, No
I set sInputBuff to that string to demonstrate how it may work.
You need to place the message text in there!
Does that make sense.
Bruce.
Yes but when I put:
VB Code:
Dim sInputBuff As String: sInputBuff = mess 'mess being the string that was sent minus the instr part.
The other client main window is empty when I send a message.
OR
do you mean:
VB Code:
Dim sInputBuff As String: sInputBuff = txtmess.text
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 26th, 2002, 05:01 AM
#25
Aaron,
From you last post it would seem that you inadvertantly re-assigned the txtMess Box (if you did it the way u mentioned). Try this:
Please note where I cut your code so u can put it back in the right spoy
VB Code:
[b]sInputBuff = mess 'Load the string buffer with the INCOMMING message (wich may contain swear words!)[/b]
End If
'check to see if there is data in the listbox that matches the message string
'Split up the String into the Array
If InStr(sInputBuff, " ") Then 'More than 1 word, so split
sInputArr = Split(sInputBuff, " ")
Else
ReDim sInputArr(0) 'Only 1 word, so place it in the Array
sInputArr(0) = sInputBuff
End If
For X = 0 To UBound(sInputArr)
For a = 0 To frmSetup.Lstblock.ListCount - 1
If UCase(frmSetup.Lstblock.List(a)) = UCase(sInputArr(X)) Then sInputArr(X) = "*****"
Next
Next
[b]txtMess.Text = Join(sInputArr) 'Write out to the TextBox the 'corrected' message text. ie hashed out the swear words.[/b]
[b]txtMess.SelStart = Len(mess)[/b]
[b]txtMess.SetFocus[/b] 'I also added this.
End Sub
Bruce.
-
Sep 26th, 2002, 05:18 AM
#26
Originally posted by Bruce Fox
VB Code:
[b]sInputBuff = mess 'Load the string buffer with the INCOMMING message (wich may contain swear words!)<b>Aaron,
From you last post it would seem that you inadvertantly re-assigned the txtMess Box (if you did it the way u mentioned). Try this:
Please note where I cut your code so u can put it back in the right spoy <img src="images/smilies/smile.gif" border="0" alt="" title="Smilie" class="inlineimg" />
</b>
End If
'check to see if there is data in the listbox that matches the message string
'Split up the String into the Array
If InStr(sInputBuff, " ") Then 'More than 1 word, so split
sInputArr = Split(sInputBuff, " ")
Else
ReDim sInputArr(0) 'Only 1 word, so place it in the Array
sInputArr(0) = sInputBuff
End If
For X = 0 To UBound(sInputArr)
For a = 0 To frmSetup.Lstblock.ListCount - 1
If UCase(frmSetup.Lstblock.List(a)) = UCase(sInputArr(X)) Then sInputArr(X) = "*****"
Next
Next
[b]txtMess.Text = Join(sInputArr) 'Write out to the TextBox the 'corrected' message text. ie hashed out the swear words.[/b]
[b]txtMess.SelStart = Len(mess)[/b]
[b]txtMess.SetFocus[/b] 'I also added this.
End Sub
Bruce. [/B]
Thanx it worked but I am still having trouble if there is only one word being sent. I was wondering if a could get the number of * characters to match the word being blocked number of chacters?
Last edited by Nightwalker83; Sep 26th, 2002 at 05:23 AM.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 26th, 2002, 05:29 AM
#27
Hmmm,
That was one of the tests I checked. Note how I commented the code
to place a series of words, or one word into the Array......
And I was going to assign the number of "*" to the lenght of each
word... but I ran outa time ... - You give it ago, youll figure it out.
Bruce.
-
Sep 26th, 2002, 06:41 AM
#28
Originally posted by Bruce Fox
Hmmm,
That was one of the tests I checked. Note how I commented the code
to place a series of words, or one word into the Array......
And I was going to assign the number of "*" to the lenght of each
word... but I ran outa time ... - You give it ago, youll figure it out.
Bruce.
I tried the REPLACE function but I couldn't figure out how to make the number of "*" to equal the len of the word.
Last edited by Nightwalker83; Sep 26th, 2002 at 06:54 AM.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 27th, 2002, 04:17 AM
#29
Originally posted by Nightwalker83
I was wondering if a could get the number of * characters to match the word being blocked number of chacters?
Use the String Function; like:
VB Code:
If LCase(List1.List(i)) = LCase(sInputArr(x)) Then sInputArr(x) = [b]String(Len(List1.List(i)), "*")[/b]
Bruce.
-
Sep 28th, 2002, 10:09 PM
#30
Originally posted by Bruce Fox
VB Code:
If LCase(List1.List(i)) = LCase(sInputArr(x)) Then sInputArr(x) = [b]String(Len(List1.List(i)), "*")<b>Use the <b>String</b> Function; like:
</b>
Bruce. [/B]
Thanx it works great
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 30th, 2002, 03:21 AM
#31
Bruce,
I am using this code to replace the words:
VB Code:
If InStr(sInputBuff, " ") Then 'More than 1 word, so split
sInputArr = Split(sInputBuff, " ")
Else
ReDim sInputArr(0) 'Only 1 word, so place it in the Array
sInputArr(0) = sInputBuff
End If
For x = 0 To UBound(sInputArr)
For a = 0 To frmSetup.Lstblock.ListCount
If UCase(frmSetup.Lstblock.List(a)) = UCase(sInputArr(x)) Then sInputArr(x) = String(Len(frmSetup.Lstblock.List(a)), "*")
Next a
Next x
txtMess.Text = Join(sInputArr) 'Write out to the TextBox the 'corrected' message text. ie hashed out the swear words.
txtMess.SelStart = Len(mess)
End Sub
I am have trouble because if I have one word or even two words in the listbox it works. If I have three or more words it the listbox it will not hash out all the words in the listbox. The program changes the words being hashed out each time which I don't want. I want all the words in the listbox to be hashed out.
Could you please help me solve this problem.
Thanx
Aaron
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 17th, 2002, 12:00 AM
#32
I have just about had it with this stupid thing. The code works fine in a test program I have made but it will not work in my chat app.
VB Code:
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Winsock1(intmax).GetData str
If InStr(1, str, "|END|") <> 0 Then
End
End If
Dim sInputArr() As String
Dim sInputBuff As String
'Get the message string
If InStr(1, str, "|MESSAGE|") <> 0 Then
mess = Mid$(str, 10, Len(str))
sInputBuff = mess 'Load the string buffer with the INCOMMING message (wich may contain swear words!)
End If
'Check to see if there is data in the listbox that matches the message string
'Split up the String into the Array
If InStr(sInputBuff, " ") Then 'More than 1 word, so split
sInputArr = Split(sInputBuff, " ")
Else
ReDim sInputArr(0) 'Only 1 word, so place it in the Array
sInputArr(0) = sInputBuff
End If
For x = 0 To UBound(sInputArr)
For a = 0 To frmSetup.Lstblock.ListCount - 1
If UCase(frmSetup.Lstblock.List(a)) = UCase(sInputArr(x)) Then sInputArr(x) = String(Len(frmSetup.Lstblock.List(a)), "*")
Next a
Next x
txtmess.Text = txtmess.Text & Join(sInputArr, " ") 'Write out to the TextBox the 'corrected' message text. ie hashed out the swear words.
txtmess.SelStart = Len(txtmess.Text)
End Sub
Last edited by Nightwalker83; Dec 13th, 2007 at 07:45 PM.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 17th, 2002, 12:21 AM
#33
Fanatic Member
try this
What you first posted has an error I think
Try this...May be this is the thing you are looking for
For b = 0 To frmSetup.LstBlock.ListCount
If Text1.Text = frmSetup.LstBlock.List(b) Then
MsgBox ("Word is not allowed")
Else
If Text1.Text = "" or frmSetup.LstBlock.listcount=0 Then
Exit Sub
End If
End If
Next b
frmSetup.Show
End Sub
-
Oct 18th, 2002, 01:09 AM
#34
Aaron,
I unzipped both apps, and it ran fine!
I was able to type a string like : "this is a test" in the
Clien TYextBox, and the message appeared like "this is a ****"
in the Server end????
It worked great! whats it not doing your end?
(I had to add the WindSock Component)
Bruce.
-
Oct 18th, 2002, 01:55 AM
#35
Originally posted by Bruce Fox
Aaron,
I unzipped both apps, and it ran fine!
I was able to type a string like : "this is a test" in the
Clien TYextBox, and the message appeared like "this is a ****"
in the Server end????
It worked great! whats it not doing your end?
(I had to add the WindSock Component)
Bruce.
I can get the client/sever demo to work except when I copy and paste the code in to my chat app it doesn't work properly.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 18th, 2002, 02:17 AM
#36
KING BODWAD XXI
Use Split Command to split the words then check them
Array = split(String," ")
-
Oct 18th, 2002, 02:26 AM
#37
Originally posted by BodwadUK
Use Split Command to split the words then check them
Array = split(String," ")
Thanks BodwadUK, but thats what were doing
-
Oct 18th, 2002, 04:42 AM
#38
KING BODWAD XXI
-
Oct 18th, 2002, 07:46 AM
#39
Thanx Bruce
VB Code:
'Check to see if there is data in the listbox that matches the message string
'Split up the String into the Array
sInputBuff = Replace(sInputBuff, "Aaron Says:", "")
If InStr(sInputBuff, " ") > 0 Then 'More than 1 word, so split
sInputArr = Split(sInputBuff, " ")
Else
ReDim sInputArr(0) 'Only 1 word, so place it in the Array
sInputArr(0) = sInputBuff
End If
For x = 0 To UBound(sInputArr)
For a = 0 To frmSetup.Lstblock.ListCount - 1
'The following line removes vbCrLf from the array
sInputArr(x) = Replace(sInputArr(x), vbCrLf, "")
If UCase(frmSetup.Lstblock.List(a)) = UCase(sInputArr(x)) Then sInputArr(x) = String(Len(frmSetup.Lstblock.List(a)), "*")
Next a
Next x
txtMess.Text = txtMess.Text & Join(sInputArr, " ") & vbCrLf 'Write out to the TextBox the 'corrected' message text. ie hashed out the swear words.
txtMess.SelStart = Len(txtMess.Text)
End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 18th, 2002, 08:02 AM
#40
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
|