Results 1 to 13 of 13

Thread: VB Hangs Up

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    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:
    1. Option Explicit
    2. Private Pline(60) As String
    3.  
    4. Private Sub Form_Load()
    5.    Prepare_string
    6.    Print_string
    7.    
    8.    Unload Me
    9.    End
    10. End Sub
    11.  
    12. Private Sub Prepare_string()
    13.    Dim i As Integer, j As Integer
    14.    
    15.    For i = 1 To 60
    16.        For j = 1 To 80
    17.            Pline(i) = Pline(i) & "X"
    18.        Next
    19.    Next
    20. End Sub
    21.  
    22. Private Sub Print_string()
    23.    Dim i As Integer
    24.    
    25.    Open "lpt1:" For Output As #1
    26.    
    27.    For i = 1 To 60
    28.        Print #1, Pline(i)
    29.    Next
    30.    
    31.    Close #1
    32. End Sub

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    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.

  3. #3
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    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.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    Re: VB Hangs Up

    how can I single step the CODE?

  5. #5
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    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.

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    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.

  8. #8
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    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.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    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?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    Re: VB Hangs Up

    I unhooked the cable to my printer and the code still does the same exact thing

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    Re: VB Hangs Up

    I forgot to tell you that my printer is hooked up to the USB port right now.

  12. #12
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    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.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    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
  •  



Click Here to Expand Forum to Full Width