razree 0 Newbie Poster

Hi all
I have a simple program which calculates some values for me. Let's say I receive some money in advance, go to a trip and spend some money there (not necessary in the same currency that I received advance in.
Now if I spent more money then advanced, I have to be paid,if I spent it less I have to return it.
I have an array with all my expenses and currencies and advanced money1. If I received and spent money in the same currency it has to be calculated and result has to be printed. If currencies are not the same, all the values that I spent has to be printed along with advanced money1. Now usually there are more "spent" values but adv. money1 is only one.
Spent values are printed ok but money1 is printed for each value in ary. Where do I put "exit for" so advanced money1 is printed only once BUT only if it's currency is not the same as one of the expenses I've spent..??
Enough said, here is my code:

currencyPosition = 0
        Dim d As Integer = w + 100
        For Each currency In Ary
            If Not currency = "" Then
                For i = 0 To dt.Rows.Count - 1

                   If currency = dt.Rows(i).Item(5).ToString.Replace(" ", "") Then
                        If CDbl(dt.Rows(i).Item(4)) < CDbl(AryCurrencyValue(currencyPosition)) Then
                            e.Graphics.DrawString(("I GET THE MONEY 1 :" & " " & CDbl(AryCurrencyValue(currencyPosition)) - CDbl(dt.Rows(i).Item(4)) & "  " & currency), fnt, Brushes.Black, 200, d)
                            currencyPosition = currencyPosition + 1
                            Exit For
                        ElseIf CDbl(dt.Rows(i).Item(4)) > CDbl(AryCurrencyValue(currencyPosition)) Then
                            e.Graphics.DrawString(("I RETURN THE MONEY  11:" & "     " & CDbl(dt.Rows(i).Item(4)) - CDbl(AryCurrencyValue(currencyPosition)) & "  " & currency), fnt, Brushes.Black, 200, d + 50)
                            currencyPosition = currencyPosition + 1
                            Exit For
                        End If
                        Else
                        e.Graphics.DrawString(("I GET THE MONEY 111:" & " " & CDbl(AryCurrencyValue(currencyPosition)) & "  " & currency), fnt, Brushes.Black, 200, d + 25)

                        currencyPosition = currencyPosition + 1 
                        d = d + 25

                        If Not dt.Rows(i).Item(4) = Nothing Then
                            MessageBox.Show(currency)
                            e.Graphics.DrawString("I RETURN THE MONEY :" & "     " & dt.Rows(i).Item(4) & "   " & dt.Rows(i).Item(5), fnt, Brushes.Black, 200, d + 200)
                           End if
                        Exit For
                    End If
                next

one more thing: items 4 & 5 are value that I've spent and it's currency.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.