|
-
Oct 28th, 2005, 03:19 AM
#1
Thread Starter
Hyperactive Member
VB Hangs Up
I am trying to test my printing and my VB is saying 'NOT RESPONDING'
I have to kill it then restart, what am I doing wrong here?
VB Code:
Option Explicit
Private Pline(60) As String
Private Sub Form_Load()
Prepare_string
Print_string
Unload Me
End
End Sub
Private Sub Prepare_string()
Dim i As Integer, j As Integer
For i = 1 To 60
For j = 1 To 80
Pline(i) = Pline(i) & "X"
Next
Next
End Sub
Private Sub Print_string()
Dim i As Integer
Open "lpt1:" For Output As #1
For i = 1 To 60
Print #1, Pline(i)
Next
Close #1
End Sub
-
Oct 28th, 2005, 03:22 AM
#2
Thread Starter
Hyperactive Member
Re: VB Hangs Up
Forgot to tell you that right now I don't have the Dot Matrix printer. I have an HP DeskJet 952C hooked up to my parallel port. My form has nothing on it.
-
Oct 28th, 2005, 03:26 AM
#3
Re: VB Hangs Up
I have nothing connected to my parallel port. The code runs fine for me.
What happens if you disconnect the DeskJet?
Try single stepping through the code. Where does it hang?
This world is not my home. I'm just passing through.
-
Oct 28th, 2005, 03:29 AM
#4
Thread Starter
Hyperactive Member
Re: VB Hangs Up
how can I single step the CODE?
-
Oct 28th, 2005, 03:31 AM
#5
Re: VB Hangs Up
Normally you'd press <F5> to start the program. Instead, press <F8>. Every time you press <F8> the code steps on to the next line.
You can also set breakpoints (put your cursor on a line of code and press <F9>. The code will stop when it gets to the breakpoint.
If you hover the mouse pointer over the variables in your code while single-stepping the value of the variable will be displayed in a tooltip.
This world is not my home. I'm just passing through.
-
Oct 28th, 2005, 03:35 AM
#6
Re: VB Hangs Up
Aside from the Form_Load have you tried putting the processing inside a click event of a command button? If not then try it... Put an error handler also...
-
Oct 28th, 2005, 03:35 AM
#7
Thread Starter
Hyperactive Member
Re: VB Hangs Up
ok it is hanging up in the Print #1, Pline(i) code. It goes thru the loop for 8 to 10 times then everything hangs up and at very top in the blue bar it says Not Responding.
-
Oct 28th, 2005, 03:37 AM
#8
Re: VB Hangs Up
It sounds like the printer is storing the text you are sending in its internal buffer but not printing for some reason. When the buffer is full I guess it is refusing to accept more input - this is why VB hangs, it is waiting until it can write more data to the printer.
I think if you pulled the cable out of the LPT1 port then code execution would resume.
This world is not my home. I'm just passing through.
-
Oct 28th, 2005, 03:41 AM
#9
Thread Starter
Hyperactive Member
Re: VB Hangs Up
so you think this method of printing will not work on this kind or any of this kind of printer? it will work for Dot Matrix printers only?
-
Oct 28th, 2005, 03:43 AM
#10
Thread Starter
Hyperactive Member
Re: VB Hangs Up
I unhooked the cable to my printer and the code still does the same exact thing
-
Oct 28th, 2005, 03:46 AM
#11
Thread Starter
Hyperactive Member
Re: VB Hangs Up
I forgot to tell you that my printer is hooked up to the USB port right now.
-
Oct 28th, 2005, 03:53 AM
#12
Re: VB Hangs Up
so you think this method of printing will not work on this kind or any of this kind of printer? it will work for Dot Matrix printers only?
I couldn't say for certain - I don't have enough experience with printers.
I unhooked the cable to my printer and the code still does the same exact thing
That's strange, seeing as it works ok on my PC. Try checking your LPT port. Assuming you're on XP go to Control Panel\System\Hardware\Device Manager\Ports\Printer Port (LPT1)\Properties\General. In the Device Status section it should say "This device is working properly".
I forgot to tell you that my printer is hooked up to the USB port right now.
I don't think that makes any difference to anything I've said. If you want to print through the USB port though you'll have to get a driver that maps virtual COM or LTP ports to the USB.
This world is not my home. I'm just passing through.
-
Oct 28th, 2005, 03:58 AM
#13
Thread Starter
Hyperactive Member
Re: VB Hangs Up
ok yes it has everything you mentioned. It is defined as ECP port and it has a check mark in where it says 'Never use any intrups'
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
|