|
-
Oct 27th, 2005, 09:51 PM
#1
Thread Starter
Fanatic Member
Form_Load()
I have put this code in the Form_Load() event and when I debuged it it counted correct and the code worked fine, however when I get to the .PrintForm method it dos'nt print the row lines or column lines, but if I replace the .printform with frmPrint.Show they do appear.
I am making the .printform call from another form but I think i'm using it correctly as you can see from below.
any ideas?
VB Code:
Private Sub Form_Load()
picWindow.Left = 0
picWindow.Width = Me.Width
picI_Print.Left = 0
picI_Print.Width = picWindow.Width
Dim i As Integer
Dim t As Integer
t = 2775
For i = 1 To 54 ' Add Line Numbers
t = t + 225 ' to form
picI_Print.CurrentX = 0
picI_Print.CurrentY = t
picI_Print.Print i
picI_Print.Line (0, t)-(picI_Print.Width, t) 'Make rows 225 twips apart
Next
'''' Make columns
picI_Print.Line (300, 2400)-(300, picI_Print.Height)
picI_Print.Line (750, 2400)-(750, picI_Print.Height)
picI_Print.Line (2100, 2400)-(2100, picI_Print.Height)
picI_Print.Line (3525, 2400)-(3525, picI_Print.Height)
picI_Print.Line (4500, 2400)-(4500, picI_Print.Height)
End Sub
Private Sub Command4_Click()
Me.Hide
Load frmPrint
frmPrint.PrintForm
End Sub
Edit: Added [vbcode][/vbcode] tags for clarity. - Hack
Last edited by Hack; Oct 31st, 2005 at 07:52 AM.
-
Oct 27th, 2005, 09:59 PM
#2
Re: Form_Load()
Can you zip and attach your project? (I can't replicate the problem)
-
Oct 27th, 2005, 10:07 PM
#3
Re: Form_Load()
That's because you used the Form_Load() event. That event is fired before the form has even completely loaded. Use Form_Activate() instead, which fires after the Form and all of its objects have loaded 
Also be sure to use [Highlight=VB] tags when displaying vb code.
-
Oct 27th, 2005, 10:09 PM
#4
Re: Form_Load()
Place the code in the form_activate section, as the form isn't loaded in form_load. Form.Show will force the form to be shown in the load event, which is why it works.
-
Oct 27th, 2005, 10:11 PM
#5
Re: Form_Load()
Also, what does Form_Load() in your thread title have to do with your problem? A more appropriate thread title for this would be "Rows and Columns not being displayed in form"
-
Oct 27th, 2005, 10:20 PM
#6
Thread Starter
Fanatic Member
Re: Form_Load()
tried putting
VB Code:
picWindow.Left = 0
picWindow.Width = Me.Width
picI_Print.Left = 0
picI_Print.Width = picWindow.Width
Dim i As Integer
Dim t As Integer
t = 2775
For i = 1 To 54 ' Add Line Numbers
t = t + 225 ' to form
picI_Print.CurrentX = 0
picI_Print.CurrentY = t
picI_Print.Print i
picI_Print.Line (0, t)-(picI_Print.Width, t) 'Make rows 225 twips apart
Next
'''' Make columns
picI_Print.Line (300, 2400)-(300, picI_Print.Height)
picI_Print.Line (750, 2400)-(750, picI_Print.Height)
picI_Print.Line (2100, 2400)-(2100, picI_Print.Height)
picI_Print.Line (3525, 2400)-(3525, picI_Print.Height)
picI_Print.Line (4500, 2400)-(4500, picI_Print.Height)
End Sub
in activate event did'nt work either
Also I do not want to display this form. I want to be able to print it on paper
Edit: Added [vbcode][/vbcode] tags for clarity. - Hack
Last edited by Hack; Oct 31st, 2005 at 07:53 AM.
-
Oct 27th, 2005, 10:23 PM
#7
Re: Form_Load()
Why are you using twips? Set the scalemode to 3 and make it pixels. Anyways give me a minute to fix your code.....
Remember to use those [Highlight=VB] tags too.
-
Oct 27th, 2005, 10:27 PM
#8
Thread Starter
Fanatic Member
Re: Form_Load()
[QUOTE=Jacob Roman]Why are you using twips? Set the scalemode to 3 and make it pixels.
because I very new to VB
Haven't got the whole scalemode thing down yet.
bty the column lines that are show are put there by me drawing lines not via the code, the lines are there just for reference and will be deleted later on.
-
Oct 27th, 2005, 10:29 PM
#9
Re: Form_Load()
I agree with Bruce. Post your project so we can see how you are trying to do this. I thought you wanted to use a form.
-
Oct 27th, 2005, 10:34 PM
#10
Re: Form_Load()
Enjoy 
VB Code:
Option Explicit
Private Sub Form_Activate()
ScaleMode = 3
With picWindow
.ScaleMode = 3
.AutoRedraw = True
.Left = 0
.Top = 0
.Width = Me.Width
.Height = Me.Height / 2
End With
With picI_Print
.ScaleMode = 3
.AutoRedraw = True
.Left = 0
.Top = Me.ScaleHeight / 2
.Width = Me.Width
.Height = Me.Height / 2
End With
'Long is the fastest computing data type, and theres no worry for overflow ;)
Dim i As Long
Dim t As Single
t = 2.7
For i = 1 To 54 ' Add Line Numbers
t = t + 22.5 ' to form
picI_Print.CurrentX = 0
picI_Print.CurrentY = t
picI_Print.Print i
picI_Print.Line (0, t)-(picI_Print.Width, t) 'Make rows 225 twips apart
Next i
'''' Make columns
picI_Print.Line (30, 0)-(30, picI_Print.Height)
picI_Print.Line (75, 0)-(75, picI_Print.Height)
picI_Print.Line (210, 0)-(210, picI_Print.Height)
picI_Print.Line (355, 0)-(352, picI_Print.Height)
picI_Print.Line (450, 0)-(450, picI_Print.Height)
End Sub
Last edited by Jacob Roman; Oct 31st, 2005 at 09:36 AM.
-
Oct 27th, 2005, 10:40 PM
#11
Thread Starter
Fanatic Member
Re: Form_Load()
hope this works for ya
the two form that work together
first is frmVinyl, the user GUI
second fmrPrint is the printed version(or will be) of frmVinyl
I will also have another form that will be displayed for a Preview of what is going to be printed.
the reasoning behind not showing the form is that I can print a full page, not just what you can see. other words not resolution dependit, from what I know the printform method will only print what you can see, hence two forms.
copy and paste code in still don't print (on paper) row lines and column lines.
Last edited by crater; Oct 27th, 2005 at 10:45 PM.
Reason: reply
-
Oct 27th, 2005, 10:44 PM
#12
Re: Form_Load()
I see what you are trying to do. I'm not sure if you are aware of this but there's an object in VB that's similar to Excel and Access that looks like what you were trying to simulate. So you just did all that work for nothing, and could have made your life a whole lot easier.
 Originally Posted by crater
Haven't got the whole scalemode thing down yet.
Don't worry bout getting down the scalemode. Set it to 3 - Pixels on all of your forms/pictureboxes that you plan on drawing on and you don't have to worry about a thing. Set it and forget it.
Last edited by Jacob Roman; Oct 27th, 2005 at 10:53 PM.
-
Oct 28th, 2005, 01:11 AM
#13
Lively Member
Re: Form_Load()
Crater,
I don't know why you are using a form to draw lines and then print it on the paper, instead you may use the printer object to do this.
you can print lines, text, images, use different fonts and colors with printer object
You can also select your printer for printer object.
Sanjay
-
Oct 30th, 2005, 10:59 PM
#14
Thread Starter
Fanatic Member
Re: Form_Load()
Sorry about the last forms I attached.
I have created a new project that will show you what I'm trying to do.
as you can see the form prints on the screen fine but when it goes to print it on paper the rows and columns do not show. Any ideas would be great.
I understand that the form is not active until it is shown or is activated, but here in this case I can still show it (that would automatically activate it) and it still dose'nt do both print on screen and a copy on paper.
Last edited by crater; Oct 30th, 2005 at 11:27 PM.
-
Oct 31st, 2005, 09:03 AM
#15
Re: Form_Load()
Jacob, Long may be the fastest data type (on 32-bit platforms), but there's no point in hell setting a Long to 2.7 ... it's still an integer you know
-
Oct 31st, 2005, 09:34 AM
#16
Re: Form_Load()
 Originally Posted by penagate
Jacob, Long may be the fastest data type (on 32-bit platforms), but there's no point in hell setting a Long to 2.7 ... it's still an integer you know 
That's why you use Single. It's another 32 bit data type, only for decimals
-
Oct 31st, 2005, 09:36 AM
#17
Re: Form_Load()
Indeed... I was simply referring to this:
 Originally Posted by Jacob Roman
VB Code:
Dim i As Long
Dim t As Long
t = 2.7
-
Oct 31st, 2005, 09:37 AM
#18
Re: Form_Load()
I fixed it
-
Oct 31st, 2005, 09:38 AM
#19
Re: Form_Load()
 Originally Posted by crater
Sorry about the last forms I attached.
I have created a new project that will show you what I'm trying to do.
as you can see the form prints on the screen fine but when it goes to print it on paper the rows and columns do not show. Any ideas would be great.
I understand that the form is not active until it is shown or is activated, but here in this case I can still show it (that would automatically activate it) and it still dose'nt do both print on screen and a copy on paper.
The reason why is because you practically ignored the code I gave you in Post #10. Mine printed flawlessly, yours didn't.
-
Oct 31st, 2005, 09:45 PM
#20
Thread Starter
Fanatic Member
Re: Form_Load()
 Originally Posted by Jacob Roman
The reason why is because you practically ignored the code I gave you in Post #10. Mine printed flawlessly, yours didn't.
not so Jacob I actually copyed and pasted you code into my form and it did'nt work.
so maybe a screwed something up, so I tried it again and now i get a run-time error 480: Application defined or object defined error.
when I debug if highlites this line.
So now I'm really lost
Q1: Your code should be in the frmPrint form? Because the only other code in that form is cmdexit that unloads the form.
Q2: should I be calling frmPrint VIA .show from frmVinyl? or is there another way to call the activate event in frmPrint?
Please don't get discouraged, I am very new to VB and just want to learn.
-
Nov 1st, 2005, 09:42 AM
#21
Re: Form_Load()
Did you make a new project with only one form, add two pictureboxes, and then do it? Try that and it should work now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|