I try to migrate an old QBasic program, for reading from a serial device (COM-port), to Visual Basic 6.
I use this code (this original code should work for VB6 also):
RESET
OPEN "COM1:2400,E,7,2,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, "SND1"
LINE INPUT #1, P$
This works fine with QBasic (sending 'SND1' gives me the data from the device), but VB6 gives an error at the PRINT
-command: 'Bad file mode' (error 54).
If I change FOR RANDOM
to FOR OUTPUT
the PRINT
-commands works, but then the LINE INPUT
-command gives the same error (of course).
UPDATE:
The only options for 'mode' (see: http://msdn.microsoft.com/en-us/library/aa266177(v=vs.60).aspx) are Append, Binary, Input, Output, or Random.