|
-
Jul 11th, 2000, 03:13 PM
#1
Thread Starter
Addicted Member
Hi.
I forgot which string function will return the number of times the word "the" was found in the string "the lion is the king of the jungle".
thanks
-
Jul 11th, 2000, 04:16 PM
#2
Hyperactive Member
I never new about this function , but you can make one like:
Private Sub Form_Load()
MsgBox returnThe("the lion is the king of the jungle")
End Sub
Private Function returnThe(theString As String) As Integer
Dim counter
counter = 0
Do
place = InStr(theString, "the")
theString = Right(theString, Len(theString) - place)
If place <> 0 Then counter = counter + 1
Loop While place <> 0
returnThe = counter
End Function
In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.
- Douglas Adams
The Hitchhiker's Guide to the Galaxy
-
Jul 11th, 2000, 04:16 PM
#3
I dont know if there is a function but here is some code i modified to do the same job. Hope it helps.
[/CODE]
Dim x As Integer
Dim string1 As String
Dim string2 As String
Dim count As Integer
string1 = "the lion is the king of the jungle"
string2 = "the"
x = 1
count = 0
Do Until x = 0
x = InStr(x, string1, string2, 1)
If x > 0 Then
count = count + 1
x = x + 1
End If
Loop
MsgBox count
[/CODE]
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
|