|
-
Jul 21st, 2004, 01:20 PM
#1
Thread Starter
New Member
Array Problems? o.O
ok, i'm going to try to be as unvague as possible. Umm basically i have information stored in an array we can called "ArrayA". Each element in the array is a searchword that reads a text file and finds a match, its read the text file line by line and it basically stores the line if it finds a match. Once a match is found, it jumps to the next search word in ArrayA and searches the same line over again to see if it finds a match, if it does it stores it into an array (all the searchresults are stored into the same array so it just adds on to the end of the array). This process basically repeats till it has gone thorugh all the searchwords, then it moves on to the next line and repeats the process for the entire document.
But i sort of want it so that everytime the first searchword finds a word, it'll store it in an element like what it does now, but when it moves on to the next line, i want is to that intead of adding to the array, if the first searchword finds another match i want it to add on to the element that the first line is stored in. and so on for all the searchwords
is that possible?
PS: i would show you my code, but its company property and its also my first code so it's kinda ugly and very unorganized
tell me if what i just said didn't make any sense....
-
Jul 22nd, 2004, 12:42 AM
#2
Fanatic Member
this?
VB Code:
Dim s1 As String = "the brown monkey is not me really but they call me at that name"
Dim s2 As String() = Split(s1, " ")
Dim s3 As String() = {"monkey", "me", "but", "at"} ' words to search
Dim s4 As String
Dim s As New Stack()
For Each s4 In s2
Dim s5 As String
For Each s5 In s3
If s4 = s5 Then
s.Push(s4)
End If
Next
Next
Dim s6 As String
For Each s4 In s2
s6 &= s4 & Constants.vbCrLf
Next
MessageBox.Show(s6)
s6 = ""
For Each s4 In s
s6 &= s4 & Constants.vbCrLf
Next
MessageBox.Show(s6)
-
Jul 22nd, 2004, 05:55 AM
#3
PowerPoster
Hi brown monkey,
May be it's just old age but I cant see where you have stored any value in s4. Also you are trying to declare more than one instance of s5 - again with no value.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 22nd, 2004, 06:09 AM
#4
Fanatic Member
hello taxes. i just use s4 to loop through array and stack. s5 is used to loop through array too but in my case, it's the words to be searched.
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
|