I am having a problem convering some code from VB.Net to VB6

I have a Verfone terminal and a test project from Verifone that is written in .NET.  Most of it I can decipher but sending the string to the terminal has me stumped.
    Private WithEvents mobjRS232 As New System.IO.Ports.SerialPort is the definition of the item? that is used to send requests to the terminal in .NET.

I am not sure what is comparable in VB6 but I am trying to use an MSComm control and can't get it to work.

It appears that .NET is sending the information in binary.  How would I go about doing the same in VB6?

Thanks in advance for considering my question

JDL129

VB.net code
                 Dim abytSendData() As Byte
                Dim SQL As String
                SQL = strSendString
                ReDim abytSendData(strSendString.Length - 1)
                For i = 0 To strSendString.Length - 1
                    abytSendData(i) = Asc(strSendString.Substring(i, 1))
                Next
                Try
                    mobjRS232.Write(abytSendData, 0, abytSendData.Length)
                Catch ex As Exception
                    UpdateLog("Error Sending " & abytSendData.ToString, "")
                End Try
 
VB6 CODE
 
 
        If strSendString <> chr(ACK) Then
                strSendString = chr(STX) & strSendString & chr(ETX)
            strLRC = chr(ComputeLrc(strSendString))
                strSendString = strLRC & strSendString
        End If
 
                Dim abytSendData() As String
                Dim SQL As String
                SQL = strSendString
                ReDim abytSendData(Len(strSendString) - 1)
                For i = 1 To Len(strSendString) - 1
                    strString = Asc(Mid(strSendString, i, 1))
                    abytSendData(i) = Asc(Mid(strSendString, i, 1))
                Next
                    varSend = "abytSendData, 0,  Len(abytSendData)"
                    MSComm1.Output = strSendString

Open in new window

JDL129Asked:
Who is Participating?
 
game-masterConnect With a Mentor Commented:

on your vb6 code. try to remove chr or asc then
check the value of strSendString

game-master
0
 
game-masterCommented:


good morning@

are u using serial port?
what is the setting of your MSComm control?
different MSComm setting has different output.

game-master
0
 
JDL129Author Commented:
good morning to you!!
Actually this uses a program to create a com 5 and connects via USB.  The Com settings are:
CommPort = 5
InBufferSize = 1024
DTRenable = True
EOFEnable = False
Handshaking = 0-comNone
InBufferSize = 1024
Index = blank
InputLen = 0
InputMode = 0-comInputModeText
NullDiscard = False
OutBufferSize = 512
ParityReplace = ?
RThreshold = 0
RTSEnable = False
Settings = 9600,n,8,1
SThreshold = 0

Program changes:
Public Const kInit = "115200,N,8,1"

Top and Left I didn't figure you needed.

THANKS FOR YOUR RESPONSE!

Jerry
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
game-masterCommented:

in .NET the data is send in binary (Asc), however in vb6, u dont need to convert
data to that format...remove the chr on your vb6 code.

**Debug your application, check if what is the value of the strSendString.


game-master
0
 
JDL129Author Commented:
game-master,

Do you mean remove chr or ASC?

Thanks,

Jerry
0
 
JDL129Author Commented:
game-master:

what this code does is send a string to a Verifone MX870 terminal that is used in POS systems.  So far nothing I have tried has returned responses from the terminal.

Thanks for the response,

Jerry
0
 
exp2201Commented:
End of question
game-master,
Thanks for you response

0
 
JDL129Author Commented:
Thanks for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.