Posted: December 10 2002 at 21:02 | IP Logged
|
|
|
Well, I'm not proud, but, it should work. Start with a blank form, add an MSCOMM object, set your baud rate and such, and paste in this code...
Private Sub Form_Load()
' serout.exe ' Usage: serout [/n] [string to send to serial port] ' n is comm port (2 is default)
' Ex. serout /3 Hello world! ' Sends "Hello world!" to com3
' Get command line arguments args = Command()
' Start out on COM2 (my modem for testing) Port = 2
' Look for a different comm port switch (i.e. /1 for comm1) If InStr(args, "/") <> 0 Then arglen = Len(args) ' Get string length slashpos = InStr(args, "/") ' Find the slash Port = Mid$(args, slashpos + 1, 1) ' Pull out the port number args = Mid$(args, slashpos + 3, arglen - 3) ' from the arguments End If
MSComm1.CommPort = Port ' Select the port MSComm1.PortOpen = True ' Open it MSComm1.Output = args ' Send the string
MSComm1.PortOpen = False ' Close the port
End ' All done!
End Sub
Let me know if you meant for me to post the exe!
Tony
|