Results 1 to 4 of 4

Thread: Array Problems? o.O

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    13

    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....

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    this?
    VB Code:
    1. Dim s1 As String = "the brown monkey is not me really but they call me at that name"
    2.       Dim s2 As String() = Split(s1, " ")
    3.       Dim s3 As String() = {"monkey", "me", "but", "at"} ' words to search
    4.  
    5.       Dim s4 As String
    6.       Dim s As New Stack()
    7.       For Each s4 In s2
    8.          Dim s5 As String
    9.          For Each s5 In s3
    10.             If s4 = s5 Then
    11.                s.Push(s4)
    12.             End If
    13.          Next
    14.       Next
    15.  
    16.       Dim s6 As String
    17.       For Each s4 In s2
    18.          s6 &= s4 & Constants.vbCrLf
    19.       Next
    20.       MessageBox.Show(s6)
    21.       s6 = ""
    22.       For Each s4 In s
    23.          s6 &= s4 & Constants.vbCrLf
    24.       Next
    25.       MessageBox.Show(s6)

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  4. #4
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    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
  •  



Click Here to Expand Forum to Full Width