|
-
May 8th, 2002, 07:06 PM
#1
Thread Starter
Member
using a print function in visual basics
hi, im having some real trouble getting my program to print my source code,
here is the code im using
Private Sub Print_Click()
Dim BeginPage, EndPage, NumCopies, i
' Set Cancel to True
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' Display the Print dialog box
CommonDialog1.ShowPrinter
' Get user-selected values from the dialog box
BeginPage = CommonDialog1.FromPage
EndPage = CommonDialog1.ToPage
NumCopies = CommonDialog1.Copies
For i = 1 To NumCopies
' Put code here to send data to the printer
Next i
Exit Sub
ErrHandler:
' User pressed the Cancel button
Exit Sub
End Sub
I have a commondialog box, i found out how to print the form, but I can not find out how to print my source code, if any of you could help, it would be greatly appriated
thanks
-
May 8th, 2002, 07:12 PM
#2
-= B u g S l a y e r =-
u will have to open all the files that u'r project consists of and print it...
frm, cls, clt, bas ...
is that what u want to do?
-
May 8th, 2002, 07:13 PM
#3
Stuck in the 80s
If you want to print your source code of the current application directly from the VB IDE through your app (whoa, confusing), it's not going to work. You're going to have to open the .frm file through your app to get the text.
As for how exactly to print: A search on these forums will give you many many examples.
-
May 8th, 2002, 07:15 PM
#4
Thread Starter
Member
I have pull down menus in my program, it consists of 6 forms,
I want to be able to start the program, go to the pull down menu file, go to print, and be able to print the entire source code I used for the lab. I just cant figure out how to print source in run time
-
May 8th, 2002, 07:18 PM
#5
Stuck in the 80s
are you typing the source into your program? or are you trying to get it from the VB IDE?
You're going to have to load each file that's used by your project into a string and then print it. You can't just retrieve the source through code and print it.
-
May 8th, 2002, 07:27 PM
#6
Thread Starter
Member
so what youre sayign is that there is no way I would be able to print my source code, by using the code I had used above, im some what a beginner so try not to use words or phrases I might not understand
-
May 8th, 2002, 07:37 PM
#7
-= B u g S l a y e r =-
You have to open the files that your project consist of, and then print it.
VB Code:
Private Sub Command3_Click()
CommonDialog1.ShowPrinter
Open "C:\MyApp\Form1.frm" For Binary As #1
s = Input(LOF(1), 1)
Close #1
Printer.Print s, CommonDialog1.hDC
Printer.EndDoc
End Sub
the sample will print source code (and some) of the From1 in the project located in C:\MyApp
-
May 8th, 2002, 07:55 PM
#8
Thread Starter
Member
im still lost here, I put the code
CommonDialog1.ShowPrinter
Open "C:\Kyle\Computer Science and Design Grade 10\Lab 10\Form1.frm" For Binary As #1
s = Input(LOF(1), 1)
Close #1
Printer.Print s, CommonDialog1.hDC
Printer.EndDoc
in every command and just everything in my form, then so I still need the code I used in the very first part, so when I click my print button it should print the code in what ever commands I put that code commondialog.showprint
open.............
please help
-
May 8th, 2002, 08:52 PM
#9
Well if you compile your code into an exe then there is no code to print considering that it got compiled to machine lingo so the idea of printing code at runtime wont work. Having said that you can do like the others suggested and open the actually files (.frm, .mod, .prj) and print them OR even better from the IDE (since you'll need to print at desing time anyway) you can go to the menu at the top of the IDE and click FILE then PRINT, select 'Current Project', check 'Code' and hit Ok and it'll print all your source code for ya!
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
|