Solved

Filter: What have i done wrong

Posted on 2004-04-15
13
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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 86

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 86

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

717 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