Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for - next help

Status
Not open for further replies.

compcad

Programmer
Mar 22, 2002
52
0
0
US
i have posted under this subject before except it is different than the last time and i am trying to use the caps in this post to distinguish the code i am trying to get accross
hi

i have a picturebox with a picture image in it the image name is: PICADDRESS.BMP.

this is the code i am using to get it to paper:
Printer.PaintPicture picAddress, 7600, a + 500, 4000, 2500

is what i want to do is put this image in four spots on a sheet of paper and so i am using this counter:
a = 200
a = a + 3800

i then also would like to be able to enter a START NUMBER and a END NUMBER and then have it to print this image on multiple pages until the start and end number have been reached. here is the code i have been trying to use to accomplish this task. there always needs to be four images per page except if the total number of images comes up short shuch as if i had 15 images they would end up printing on a total of 3 and a part of another sheet of paper or if i have 1 image then it will print on a part of a single sheet of paper

Dim nIndex
Dim start, end, a
start = Text1
end = Text2
a = 200
For nIndex = start To end
Printer.PaintPicture picAddress, 7600, a + 500, 4000, 2500
a = a + 3800
next nIndex

Printer.NewPage
End
End

i need to be able to use numbers such as:

START NUMBER: 1 THROUGH 4000
END NUMBER: 1 THROUGH 4000

THANK YOU
STEPHEN MENTZER
 
I notice that you still haven't yet found any of the answers given as helpful. Try re-reading faq222-2244 if you need help with framing questions or acknowledging answers.

For your current question, your code appears to work fine for me, with a couple of small changes.

You can't use End as a variable name and you should specifically refer to the Picture property of the PictureBox control. At present you're not resetting your page variables at the end of the page, and you're missing an EndDoc. It's also a good idea to specify your variable types at declaration. Try this:

Private Sub Command3_Click()
Dim intIndex As Integer
Dim intStart As Integer
Dim intEnd As Integer
Dim intA As Integer
intStart = Text1.text
intEnd = Text2.text
intA = 200
For intIndex = intStart To intEnd
Printer.PaintPicture Picture1.Picture, 7600, intA + 500, 800, 500
intA = intA + 3800
If intIndex Mod 4 = 0 Then
Printer.NewPage
intA = 200
End If
Next intIndex
Printer.EndDoc
End Sub

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top