What Code Is This?

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I'm using this with Access VBA.

Open "Com1:19200,n,8,1" For Output As #1
Print #1, "Printer On"
Close #1

What code is this and where do you find out about it.

This works but I want to add an Error to it if the thing can't print it'll
send back an Error.

I also tried for Input as #1, but as I said I'm lost not having any idea
what this is. Any help appreciated. Thanks
DS
 
I'm not sure what you are asking but this code is for a serial printer on
Com1 and should print the words Printer On on the printer that is running at
19.2 Kb. Hope that helps.
 
DS said:
I'm using this with Access VBA.

Open "Com1:19200,n,8,1" For Output As #1
Print #1, "Printer On"
Close #1

What code is this and where do you find out about it.

This works in VBA??? This is BASIC code to open a serial
port for output. In this case, it looks like a serial printer is attached
to the computer. The message Printer On will be printed.
This works but I want to add an Error to it if the thing can't print it'll
send back an Error.

Add the line:
On Error Goto PrintError

in front of it and add a section after it:

End
PrintError
MsgBox("There was an error in printing")
Resume Next
I also tried for Input as #1, but as I said I'm lost not having any idea
what this is. Any help appreciated. Thanks
DS

Since File #1 is opened for output only, you can't Input from it

Get a book on Microsoft BASIC (the old style will work for this example)

Tom Lake.
 
Thanks Tom
Its becoming clearer.
I did this but...I get and error message saying PrintError not defined?
Thanks
DS

On Error Goto PrintError
Open "Com1:19200,n,8,1" For Output As #1
Print #1, "Printer On"
Close #1
End
PrintError
MsgBox("There was an error in printing")
Resume Next
 
Thanks Tom
Its becoming clearer.
I did this but...I get and error message saying PrintError not defined?
Thanks
DS

On Error Goto PrintError
Open "Com1:19200,n,8,1" For Output As #1
Print #1, "Printer On"
Close #1
End
PrintError
MsgBox("There was an error in printing")
Resume Next

Just a minor typo: to define PrintError as a label, you need a colon
after it:

PrintError:
MsgBox(...

John W. Vinson[MVP]
 
OK That worked, but doesn't work. I was hoping that it would send the error
message if the port was closed.
Thanks
DS
 
Back
Top