eslaze1catalpa
New member
- Joined
- Sep 29, 2016
- Messages
- 1
- Programming Experience
- 5-10
I have read up on how to communicate with a Comm port using VB.net code, yet I am unable to successfully convert this code to something that works. I have to upgrade my program from VB 6 to VB 2013. Please advise. Instead of posting all the code I tried and failed to get working, Here are the three Subs I need converted:
sub form_load()
With CashComm
.CommPort = v_printercomm
.Handshaking = 0
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,N,8,1"
.SThreshold = 1
End With
end sub
Private Sub CashComm_OnComm()
' MSComm listener for cash drawer
Dim dummyval As String
Select Case CashComm.CommEvent
Case comEvReceive ' Received RThreshold # of chars.
dummyval = "R"
Case comEvSend ' There are SThreshold number of characters in the transmit buffer.
dummyval = "S"
End Select
Exit Sub
sub drawercheck
If (CashComm.PortOpen = False) Then
CashComm.PortOpen = True
End If
CashComm.InputMode = comInputModeText
CashComm.Output = Chr$(&H1B) & Chr$(&H75) & Chr$(&H0)
Do
DoEvents
CashBtn.SetFocus
CARDNO.SetFocus
Buffer$ = Buffer$ & CashComm.Input
If InStr(Buffer$, Chr$(&H0)) > 0 Then
CashOpenYN = "Open"
End If
x = x + 1
Loop Until x > 5
end sub
That CashComm.output sends a message to the cash drawer, and the response tells me if it is open or closed. I have experience coding in VB 2013/VB.net, but this part is eluding me. I know MSComm is no longer used, and that I need SerialPort logic, but everything I try fails. Please help!
sub form_load()
With CashComm
.CommPort = v_printercomm
.Handshaking = 0
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,N,8,1"
.SThreshold = 1
End With
end sub
Private Sub CashComm_OnComm()
' MSComm listener for cash drawer
Dim dummyval As String
Select Case CashComm.CommEvent
Case comEvReceive ' Received RThreshold # of chars.
dummyval = "R"
Case comEvSend ' There are SThreshold number of characters in the transmit buffer.
dummyval = "S"
End Select
Exit Sub
sub drawercheck
If (CashComm.PortOpen = False) Then
CashComm.PortOpen = True
End If
CashComm.InputMode = comInputModeText
CashComm.Output = Chr$(&H1B) & Chr$(&H75) & Chr$(&H0)
Do
DoEvents
CashBtn.SetFocus
CARDNO.SetFocus
Buffer$ = Buffer$ & CashComm.Input
If InStr(Buffer$, Chr$(&H0)) > 0 Then
CashOpenYN = "Open"
End If
x = x + 1
Loop Until x > 5
end sub
That CashComm.output sends a message to the cash drawer, and the response tells me if it is open or closed. I have experience coding in VB 2013/VB.net, but this part is eluding me. I know MSComm is no longer used, and that I need SerialPort logic, but everything I try fails. Please help!