Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Loops

Posted on 2004-10-29
2
Medium Priority
?
259 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:computerg33k
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 280 total points
ID: 12445413
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
 
LVL 4

Author Comment

by:computerg33k
ID: 12445542
sounds like it'll work--but what is irow?  and it says do must end with a matching loop?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question