|
-
Jun 29th, 2000, 02:37 AM
#1
Thread Starter
Hyperactive Member
I need to know how many times a string sows up in a larger string, i.e.:
How many times does "bat" show up in
"That's bat cool batman, how bat are you?"
Anyone know?
-
Jun 29th, 2000, 03:02 AM
#2
transcendental analytic
Code:
Function wordcount(txt$, search
Dim pos As Long
If Len(txt) = 0 Then Exit Function
pos = InStr(txt, search)
Do Until pos = 0
wordcount = wordcount + 1
pos = InStr(pos + 1, txt, search)
Loop
End Function
'Usage
Msgbox wordcount (text1, "bat")
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 29th, 2000, 03:02 AM
#3
PowerPoster
Just an idea, not tested:
Code:
Dim Count as Long
Dim Temp as Long
Temp = 1
While Temp <> 0
Temp = InStr( Temp, YourText, "bat" )
if Temp > 0 Then
Temp = Temp + 1
Count = Count + 1
Endif
Wend
MsgBox "Found it " & CStr(Count) & " time" & IIf(Count = 1, "", "s")
-
Jun 29th, 2000, 03:36 AM
#4
Junior Member
Or you can write something to anti-TesticleMole virus.
MsgBox Replace("Batman is moron!", "moron", "the COOLEST person on this bat earth")
-
Jun 29th, 2000, 03:57 AM
#5
PowerPoster
Yeah, that would be a great project, let's start coding an Antivirus *g*
btw: Batman, we want you back!!!
-
Jun 29th, 2000, 08:34 AM
#6
Thread Starter
Hyperactive Member
Thanks guys, you've been really helpful. I'll be sure to mention you in my credits. BTW, the program I'm making will probably end up sucking, so if anyone's interested, when I'm finished, I'll let you tinker with it to see if anyone has any design ideas.
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
|