|
-
May 5th, 2001, 09:36 PM
#1
Thread Starter
Hyperactive Member
strings
I have a sort of interesting task. I have text loaded where I must find a certain line that starts with a certain word and then from there parse out a piece. This what I got. It find the positions ok but Im confused about having it start at the specified line and then finding the piece to parse.It hits a error where retval is (error 5) All it has to do is count the number of occurences. here's the code
Code:
hum = InStr(1, searchstring, "Human", vbTextCompare)
Do
hum = InStr(hum + 1, searchstring, "Human", vbTextCompare)
ReDim Preserve humpos(humcount)
humpos(humcount) = hum
humcount = humcount + 1
Loop While hum <> 0
counter2 = 0
For i = LBound(humpos) To UBound(humpos)
retval = InStr(humpos(i), searchstring, find, vbTextCompare)
Debug.Print
If retval Then
counter2 = counter2 + 1
End If
Next i
Debug.Print counter2
Matt 
-
May 5th, 2001, 09:51 PM
#2
Frenzied Member
This worked fine for me...
Code:
Private Sub Form_Load()
Const searchstring = "Human is a Human for Humans to Human powere Human Human oifh ajsdhfsa sfouash ukshcfas Human"
Dim humpos() As Long
hum = InStr(1, searchstring, "Human", vbTextCompare)
Do
hum = InStr(hum + 1, searchstring, "Human", vbTextCompare)
ReDim Preserve humpos(humcount)
humpos(humcount) = hum
humcount = humcount + 1
Loop While hum <> 0
counter2 = 0
For i = LBound(humpos) To UBound(humpos)
retval = InStr(humpos(i), searchstring, find, vbTextCompare)
If retval Then
counter2 = counter2 + 1
End If
Next i
Debug.Print counter2
End Sub
What are your DECLARATIONS and SEARCHSTRING?
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
May 6th, 2001, 09:54 AM
#3
Thread Starter
Hyperactive Member
I have everything declared but did not post it
What does it return when you run it?
Matt 
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
|