Can not Get Loop to Work


Author
Message
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Well an interesting thing happened. While trying to debug the above problem as Edhy recommended, since I have a DevExpress Grid on my form with a BBS I was just entering different values to see if I could find out why it did the first record and skipped all of the rest. Since I have such a few records I have always been entering data to the bottom of the grid. But this time I stopped entering about half way through the records, and in debugging I noticed it did the first record and skipped to the record that I left it on in the grid????????  I was floored. I still have no clue as to why that happens since I even reloaded my BO because I could not get the loop to work? 
But I put this statement in my code before the loop and it now seems to work great. 

Me.GridView1.MoveFirst()

I'm sure this might be logical but it seems strange to me since I did reload my BO.?
TIA.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,
Ivan's code is the correct way to handle the BO.GetEnumerable().
In your code I assume that the cword has been previously defined, but it is not really needed you can do it in a single line of code
lobo.amountinwords =  DecimalToText.ConvertDecimalToText(lobo.netcheck)

The only reason I have seen BO.GetEnumerable() going crazy is when you have a Sort or Filter and based on your original post those are cleared, so I suggest you debug the loop to see what may be happening.


Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Sorry to say that did not work either????
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Terry.

Try this one:

        For Each lobo As ResultsPerfsChecksRoughStockBO In Me.ResultsPerfsChecksRoughStockBO1.GetEnumerable
            cword = DecimalToText.ConvertDecimalToText(lobo.netcheck)
            lobo.amountinwords = cword
            y += 1
        Next


Notice you are dealing with the lobo instance created for the loop.
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
What am I missing? I tried the following code:

        'For Each lobo As ResultsPerfsChecksRoughStockBO In Me.ResultsPerfsChecksRoughStockBO1.GetEnumerable
        '    cword = DecimalToText.ConvertDecimalToText(Me.ResultsPerfsChecksRoughStockBO1.netcheck)
        '    Me.ResultsPerfsChecksRoughStockBO1.amountinwords = cword
        '    y += 1
        'Next

        ' Could Not Get the Above to Work because it would only do the First Record. So I put the following in
        MessageBox.Show(Me.ResultsPerfsChecksRoughStockBO1.Sort)
        MessageBox.Show(Me.ResultsPerfsChecksRoughStockBO1.Filter)
        MessageBox.Show(Me.ResultsPerfsChecksRoughStockBO1.Count.ToString())

The First two messageboxes show nothing and the last one shows 10 which is correct. So I tried the following code and it only does the first record also?????

               If Me.ResultsPerfsChecksRoughStockBO1.MoveFirst() Then
            ' Loop Thru All Records Making Sure NetCheck is Correct and Getting Words for Netcheck
            
            Do
                nnet = Me.ResultsPerfsChecksRoughStockBO1.checkamt + Me.ResultsPerfsChecksRoughStockBO1.groundmoney -  Me.ResultsPerfsChecksRoughStockBO1.tax
                cword = DecimalToText.ConvertDecimalToText(Me.ResultsPerfsChecksRoughStockBO1.netcheck)
                Me.ResultsPerfsChecksRoughStockBO1.amountinwords = cword
                nnet = 0.0
            Loop While Me.ResultsPerfsChecksRoughStockBO1.MoveNext()
        End If

I just can not see the trees for the forest. I know it has to be something weird I am doing but I don't know what it is. Any help would be appreciated. TIA.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search