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

Visual Basic

 
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 
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 
Sorry David, there was a typo in the code sample.

I have found another way to do what I want, however, the behaviour of the recursive function is still perplexing. Note, I have tried this with a delegate Sub and still got the same weird behaviour.

Private Delegate Sub SetNewDataRow(ByRef dt as DataTable, ByVal index As Integer, _
                         ByVal fno As Integer)

Private Sub SetNewRow(ByRef dt as DataTable, ByVal index As Integer, _
                         Optional ByVal fno As Integer = 0)
    ...

    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

          nr = dt.NewRow
          nr.ItemArray = nra
          dt.Rows.InsertAt(nr, i + 1)

          Dim del As New delRowSumm(AddressOf SetNewDataRow)
          del(dt, i + 2, fno + 1)

        End If

      End If

    Next

    dt.Rows.Add(nra)

  End Sub


It does evaluate i < dt.Rows.Count - 1 = False but jumps back into the For Loop Sniff | :^)


I got around it like this:

...

Dim fno As Integer = 0
Dim index as Integer = 0

While index <> -1

  index = SummRow(dt, index, fn)
  fno += 1

Loop

...

 Private Function SummRow(ByRef dt As DataTable, ByVal index As Integer, _
                             ByVal fno As Integer) As Integer

      Dim res As Integer = 0

      Dim arr() As Object = {"F" & (fno + 1).ToString & " Totals", _
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

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

        For j As Integer = 1 To dt.Columns.Count - 1
          If Not TypeOf dt.Rows(i).Item(j) Is DBNull Then
            arr(j) += CType(dt.Rows(i).ItemArray(j), Double)
          End If
        Next

        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 = arr
            dt.Rows.InsertAt(nr, i + 1)
            res = i + 2
            Exit For

          End If

        Else
          
          dt.Rows.Add(arr)
          res = -1
          Exit For
        End If

      Next

      Return res

    End Function


I will keep digging at the original problem though. Big Grin | :-D
I don't speak Idiot - please talk slowly and clearly

'This space for rent'

Driven to the arms of Heineken by the wife

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 
AnswerRe: Linking Databases to VB Applications Pin
Luc Pattyn4-Apr-10 5:09
sitebuilderLuc Pattyn4-Apr-10 5:09 
AnswerRe: Linking Databases to VB Applications Pin
Luc Pattyn4-Apr-10 5:13
sitebuilderLuc Pattyn4-Apr-10 5:13 

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.