ID = Submit Name = Submit> td>
TR>
TABLE>
Form>
When the above information is submitted, you can print it according to the following code.
<%
Else
"A response information from Form.
StrinterPath = Request.form ("PrinterPath")
Strusername = Request.form ("UserName")
Strpassword = request.form ("password")
StrMessage = Request.form ("Message")
WE WILL NOW Use the VBScript FileSystemObject Object and the WSH Network Object. The Network Object Will
Give US THE Methods We need to open a printer connection, and the FileSystemObject Will Allow US to Stream Our
Output to the printer. We create these Objects in The Following Code Example:
Set objfs = creteObject ("scripting.filesystemobject")
Set objWshnet = CreateObject ("WScript.Network")
"Use WSH to connect to network printers
Objwshnet.addprinterConnection "LPT1", STRPRINTERPATH, FALSE, STRUSERNAME, STRPASSWORD
"Use the file system object to use the print device as a file
Set objprinter = objfs.createtextfile ("LPT1:", TRUE
"Send text to print equipment
Objprinter.write (StrMessage)
"Turn off the print device object and make an error trap processing
ON Error ResMe next
Objprinter.close
"If an error occurs, turn off the print connection and output an error message.
IF Err THEN
Response.write ("Error #" & "& Err.Description)
Err.clear
Else
"Successful operation, output confirmation information
Response.write (" ")
Response.write (" ")
Response.write (" Print Message Send: b> td>") Response.write (" | & StrMessage &" TD > TR> ")
Response.write (" | network printer path: b> td>")
Response.write (" | & Strprinterpath &" TD> TR> ")
Response.write (" | login account: b> td>")
Response.write (" | & struserName &" TD> TR> ")
Response.write (" Table>")
Response.write (" center>")
END IF
"Cancel print connection
Objwshnet.removeprinterConnection "LPT1:"
Set objWshnet = Nothing
Set objfs = Nothing
Set objprinter = Nothing
END IF
%>
Body>
Html>
转载请注明原文地址:https://www.9cbs.com/read-6844.html
| |