We help IT Professionals succeed at work.
Get Started

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

653 Views
Last Modified: 2012-05-05
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

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE