Advertisement

12.30.2007 at 03:35AM PST, ID: 23049624
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.8

Routine to search array for value

Asked by peterdarazs in Microsoft Visual Basic.Net

Dear experts
Please help me compose/debug a routine to search, which line of an array, a given number appears.  I though a multiple loop would be able to read through my file from array (0,0) to array (120,7) but no way will it co-operate. I've used the single loop commands below with success and tested co-ordinates manually, so believe the data is good,
 
Do Until Line = 120 Or Array1(Line, Column) = SearchedForNr
                            Column = Column + 1 'or Line = Line + 1
            Loop
but the minute i put the columns and lines together  in a multiple loop they  only deliver either the first or last columns search co-ordinates. (or nothing at all)

I have enclosed the full code for this project, and have tried variations of do until/while =  <> and or with no further success and would appreciate a full scrutiny of the code as i am a beginner and have spent a whole day on this with no success. Full points for code to simply replace mine with.  am exhausted but will check in tomorrow. many thanks

**************************************************************************************************************
   
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim SourceFile As String = "C:\test.csv"
        Dim sr As New System.IO.StreamReader(SourceFile)
        Dim cvsFile() As String = sr.ReadToEnd().Split((ControlChars.Cr))
        sr.Close()
        Dim TotalNumberOfLines As Integer = cvsFile.Length - 1
        Dim TotalNumberOfColumns As Integer = 8
        Dim Array1(TotalNumberOfLines, TotalNumberOfColumns - 1) As String

        'populate array
        For i As Integer = 0 To TotalNumberOfLines
            Dim fields() As String = cvsFile(i).Split(",")
            For y As Integer = 0 To fields.Length - 1
                Array1(i, y) = fields(y).Trim()
            Next
        Next
       


        Dim SearchedForNr As Integer
        SearchedForNr = TextBox4.Text
        Dim Line As Integer = 0
        Dim Column As Integer = 0

        '*******************************************************************************
        ''''help needed on this routine:  detemine which line of array1 , contains SearchedForNr ''''
        '*******************************************************************************
        Do Until Line = 120 Or Array1(Line, Column) = SearchedForNr
            Do Until Column = 7 Or Array1(Line, Column) = SearchedForNr
                Column = Column + 1
            Loop
            Line = Line + 1
            Column = 0 ' reset counter for internal loop
        Loop
        TextBox5.Text = Line ' where SearchedForNr found
        TextBox6.Text = Column 'where SearchedForNr found

    End Sub


Many many thanks.

PeterStart Free Trial
 
Loading Advertisement...
 
[+][-]12.30.2007 at 04:12AM PST, ID: 20550528

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Sign Up Now!
Solution Provided By: appari
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628