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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

JDL129Author Commented:
game-master,

Do you mean remove chr or ASC?

Thanks,

Jerry
0
game-masterCommented:

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

game-master
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.