Click here to Skip to main content
15,894,646 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questioncompare files with hash tables, find dupe files in folder, manage hash table Pin
NikWing5-Apr-10 3:41
NikWing5-Apr-10 3:41 
AnswerRe: compare files with hash tables, find dupe files in folder, manage hash table Pin
Paramu19735-Apr-10 20:21
Paramu19735-Apr-10 20:21 
GeneralRe: compare files with hash tables, find dupe files in folder, manage hash table Pin
NikWing6-Apr-10 2:00
NikWing6-Apr-10 2:00 
GeneralRe: compare files with hash tables, find dupe files in folder, manage hash table [modified] Pin
NikWing6-Apr-10 2:21
NikWing6-Apr-10 2:21 
AnswerRe: compare files with hash tables, find dupe files in folder, manage hash table Pin
NikWing6-Apr-10 13:02
NikWing6-Apr-10 13:02 
QuestionVb.net & SQLite Pin
Ben Magee5-Apr-10 3:25
Ben Magee5-Apr-10 3:25 
AnswerRe: Vb.net & SQLite Pin
Sebastian Br.5-Apr-10 21:18
Sebastian Br.5-Apr-10 21:18 
QuestionRecursive Function [modified] Pin
Andy_L_J4-Apr-10 16:51
Andy_L_J4-Apr-10 16:51 
Maybe I have been looking at this too long.

I pass a DataTable,etc to the function. Summary values are calculated and new rows inserted at the appropriate places. The recursive part works good and the new rows are inserted into the correct place in the DataTable.

The problem occurs when the end of the DataTable is found and I call the Exit For statement, the Function should jump to the return statement, it however jumps to the Next statemnet and continues executing the loop.

Private Function SetNewDataRow(ByVal dt As DataTable, ByVal index As Integer, Optional ByVal fno As Integer = 0) As DataTable

  Dim nra(13) As Object
  nra = New Object() {"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

  nra(0) = "F" & (fno + 1).ToString & " Totals"

  For i As Integer = index To dt.Rows.Count - 1

    For j As Integer = 1 To dt.Columns.Count - 1
      If TypeOf dt.Rows(i).Item(j) Is DBNull Then

        nra(j) += 0
      Else
        nra(j) += CType(dt.Rows(i).Item(j), Double)
      End If

    Next

    '--------------------------------------
    ' Debug Info -Display array contents
    '--------------------------------------
    Dim sb As New StringBuilder()
    For n As Integer = 0 To 13
      sb.Append(nra(n))
      If n < 13 Then
        sb.Append(", ")
      End If
    Next

    Trace.WriteLine(sb.ToString)
    '--------------------------------------

    If i < dt.Rows.Count - 1 Then

      If (Left(dt.Rows(i).Item(0).ToString, 4) <> Left(dt.Rows(i + 1).Item(0).ToString, 4)) Then
        Dim nr As DataRow = dt.NewRow
        nr.ItemArray = nra
        dt.Rows.InsertAt(nr, i + 1)
        'Exit For                     ' This works

        SetNewDataRow(dt, i + 2, fno + 1)


      End If

    ElseIf i = dt.Rows.Count - 1 Then
      Dim nr As DataRow = dt.NewRow
      nr.ItemArray = nra

      dt.Rows.Add(nr)

      Exit For ' Problem here - Routine does not exit.
      ' Instead, jumps to the 'Next' statement

    End If

  Next

  Return dt

End Function


I have tried numerous things, what am I missing?

(edited code)
I don't speak Idiot - please talk slowly and clearly

'This space for rent'

Driven to the arms of Heineken by the wife
modified on Monday, April 5, 2010 8:11 AM

AnswerRe: Recursive Function Pin
riced4-Apr-10 23:41
riced4-Apr-10 23:41 
GeneralRe: Recursive Function Pin
Andy_L_J5-Apr-10 2:35
Andy_L_J5-Apr-10 2:35 
GeneralRe: Recursive Function [modified] Pin
riced5-Apr-10 4:19
riced5-Apr-10 4:19 
AnswerRe: Recursive Function Pin
William Winner7-Apr-10 8:18
William Winner7-Apr-10 8:18 
QuestionGet the parent objet or parent level in nested lists Pin
norrisMiou4-Apr-10 0:51
norrisMiou4-Apr-10 0:51 
AnswerRe: Get the parent objet or parent level in nested lists Pin
DaveAuld4-Apr-10 2:28
professionalDaveAuld4-Apr-10 2:28 
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou4-Apr-10 2:56
norrisMiou4-Apr-10 2:56 
GeneralRe: Get the parent objet or parent level in nested lists Pin
DaveAuld4-Apr-10 5:36
professionalDaveAuld4-Apr-10 5:36 
AnswerRe: Get the parent objet or parent level in nested lists Pin
Alan N4-Apr-10 6:04
Alan N4-Apr-10 6:04 
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou5-Apr-10 7:26
norrisMiou5-Apr-10 7:26 
GeneralRe: Get the parent objet or parent level in nested lists Pin
Alan N5-Apr-10 13:19
Alan N5-Apr-10 13:19 
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou5-Apr-10 15:29
norrisMiou5-Apr-10 15:29 
QuestionLinking Databases to VB Applications Pin
Razanust3-Apr-10 19:36
Razanust3-Apr-10 19:36 
AnswerRe: Linking Databases to VB Applications Pin
riced3-Apr-10 23:59
riced3-Apr-10 23:59 
AnswerRe: Linking Databases to VB Applications Pin
εїзεїзεїз4-Apr-10 0:19
εїзεїзεїз4-Apr-10 0:19 
GeneralRe: Linking Databases to VB Applications Pin
Razanust4-Apr-10 4:40
Razanust4-Apr-10 4:40 
GeneralRe: Linking Databases to VB Applications Pin
riced4-Apr-10 4:57
riced4-Apr-10 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.