Solved

Filter: What have i done wrong

Posted on 2004-04-15
13
203 Views
Last Modified: 2010-05-02
i am making a program that requires a filter and i have  got this so far, bearing that in mind, it might be all wrong.
Any answer that will work will do me fine.

heres what i got so far:

dim filteredWords, fWord() as string

filteredWords = "word1;word2;word3"
fWord = split (filterWords, ";")
for 1 = 0 to UBound(fWord)
     if InStr(1, Msg, fWord(i)) then
         msgbox (instr(1, msg, fWord(i)))
         replace msg, fWord(i), "$$$$"
     end if
next i
0
Comment
Question by:m1zz0
  • 6
  • 5
  • 2
13 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 10837833
What are you trying to accomplish?

Private Sub FilterIt()
Dim filteredWords, fWord() As String

filteredWords = "word1;word2;word3"
fWord = Split(filteredWords, ";")
For i = 0 To UBound(fWord)
     If InStr(1, msg, fWord(i)) Then
         MsgBox (InStr(1, msg, fWord(i)))
         Replace msg, fWord(i), "$$$$"
     End If
Next i
End Sub
0
 

Author Comment

by:m1zz0
ID: 10837846
i need to search through the variable 'msg' for any of the words in the filteredWords list
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10837855
Okay - then the revised should do that...
0
 

Author Comment

by:m1zz0
ID: 10837879
its not replacing the word, i did 'word1' for example, it says it is there, but the final output does not change it to "$$$$".  Any ideas?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10837912
Well, this line:
MsgBox (InStr(1, msg, fWord(i)))

Will display a message box showing the position where msg occurs in the current array string...

To replace the text,
newStr=replace (msg,fword(1),"$$$$")
0
 

Author Comment

by:m1zz0
ID: 10837967
it keeps doing something wrong,
newStr=replace (msg,fword(1),"$$$$")
keeps returning nothing, blank, but its ment to replace
ment to replace with "$$$$"
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:m1zz0
ID: 10837973
by the way, thnx for helping sirbounty, i could work on this for hours and never get it
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 10838025
Works great....

Private Sub Form_Load()
    Dim msg As String
    Dim filteredWords, fWord() As String

    msg = "The cat tried to eat the hamster but the alligator ate them both!"
    Debug.Print msg
    filteredWords = "cat;hamster;alligator"
    fWord = Split(filteredWords, ";")
    For i = 0 To UBound(fWord)
        msg = Replace(msg, fWord(i), String(Len(fWord(i)), "$"))
    Next i
    Debug.Print msg
End Sub
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10838030
So, after newstr line, you place a
MSGBOX newStr
and it doesn't come up $$$$
?
0
 

Author Comment

by:m1zz0
ID: 10838047
heres a little extra for the work, works great man, works a charm, but for some reason the debug.print thing dosent work on my computer.

Thnx sirbounty
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10838054
You need to have the immediate window open (Ctrl + G)
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 10838386
Didn't mean to swoop in and steal your thunder sirbounty.  =(

Idle_Mind
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10838397
Yea yea - I'll get you back... I've got your IP logged...
:D LOL
Hey man - no problem seriously - you picked up on it when I was still going "huh?"
Now, I understand what he was trying to accomplish - I'm glad you came along when you did.  Thanx!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now