Loops

I have a form that pops up and shows all jobs associated with one person.  Next to each job, is a checkbox.  If the checkbox is checked I want the data printed into excel.  One job per row.  I have the first job being printed into one column--now I need a loop to do the other checkboxes.

                                            Dim i as integer = 0
                                            While (CBool(dt.Rows(iIndex).Item("To_Print")) = True)
                                                oSheet.Cells(i + 1, 1) = FileNum
                                                oSheet.Cells(i + 1, 2) = Recipient
                                                oSheet.Cells(i + 1, 3) = SSN
                                                oSheet.Cells(i + 1, 4) = RecipientAddress
                                                oSheet.Cells(i + 1, 5) = RecipientAddress2
                                                oSheet.Cells(i + 1, 6) = RecipientCity
                                                oSheet.Cells(i + 1, 7) = RecipientState
                                                oSheet.Cells(i + 1, 8) = RecipientZip
                                                oSheet.Cells(i + 1, 9) = RecipientPhone
                                                oSheet.Cells(i + 1, 10) = SpecialInstructions
                                                oSheet.Cells(i + 1, 11) = AKAofPersonServed
                                                oSheet.Cells(i + 1, 12) = ServiceManner
                                                oSheet.Cells(i + 1, 13) = StatusDate
                                                oSheet.Cells(i + 1, 14) = EmployerName
                                                oSheet.Cells(i + 1, 15) = EmployerAddress1
                                                oSheet.Cells(i + 1, 16) = EmployerAddress2
                                                oSheet.Cells(i + 1, 17) = EmployerAddress3
                                                oSheet.Cells(i + 1, 18) = EmployerAddress4
                                                oSheet.Cells(i + 1, 19) = EmployerAddress5
                                                oSheet.Cells(i + 1, 20) = PersonCompanyPhone
                                                oSheet.Cells(i + 1, 21) = Comments
                                                oSheet.Cells(i + 1, 22) = JobNum
                                                oSheet.Cells(i + 1, 23) = ClientFee
                                            End While
LVL 4
computerg33kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Arthur_WoodCommented:
change your code like this:

                                    Dim i as integer = 0
                                   
                                     do while iRow as Integer < dt.Rows.Count
                                            If  (CBool(dt.Rows(iRow).Item("To_Print")) = True)
                                                oSheet.Cells(i + 1, 1) = FileNum
                                                oSheet.Cells(i + 1, 2) = Recipient
                                                oSheet.Cells(i + 1, 3) = SSN
                                                oSheet.Cells(i + 1, 4) = RecipientAddress
                                                oSheet.Cells(i + 1, 5) = RecipientAddress2
                                                oSheet.Cells(i + 1, 6) = RecipientCity
                                                oSheet.Cells(i + 1, 7) = RecipientState
                                                oSheet.Cells(i + 1, 8) = RecipientZip
                                                oSheet.Cells(i + 1, 9) = RecipientPhone
                                                oSheet.Cells(i + 1, 10) = SpecialInstructions
                                                oSheet.Cells(i + 1, 11) = AKAofPersonServed
                                                oSheet.Cells(i + 1, 12) = ServiceManner
                                                oSheet.Cells(i + 1, 13) = StatusDate
                                                oSheet.Cells(i + 1, 14) = EmployerName
                                                oSheet.Cells(i + 1, 15) = EmployerAddress1
                                                oSheet.Cells(i + 1, 16) = EmployerAddress2
                                                oSheet.Cells(i + 1, 17) = EmployerAddress3
                                                oSheet.Cells(i + 1, 18) = EmployerAddress4
                                                oSheet.Cells(i + 1, 19) = EmployerAddress5
                                                oSheet.Cells(i + 1, 20) = PersonCompanyPhone
                                                oSheet.Cells(i + 1, 21) = Comments
                                                oSheet.Cells(i + 1, 22) = JobNum
                                                oSheet.Cells(i + 1, 23) = ClientFee
                                           End If
                                           i += 1
                                           iRow += 1
                                       End While

AW
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
computerg33kAuthor Commented:
sounds like it'll work--but what is irow?  and it says do must end with a matching loop?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.