[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-11-10
8
Medium Priority
?
577 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

0
Comment
Question by:JDL129
  • 4
  • 3
8 Comments
 
LVL 13

Expert Comment

by:game-master
ID: 22927653


good morning@

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

game-master
0
 

Author Comment

by:JDL129
ID: 22930904
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
 
LVL 13

Expert Comment

by:game-master
ID: 22935963

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:JDL129
ID: 22936672
game-master,

Do you mean remove chr or ASC?

Thanks,

Jerry
0
 
LVL 13

Accepted Solution

by:
game-master earned 2000 total points
ID: 22936834

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

game-master
0
 

Author Comment

by:JDL129
ID: 22947307
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
 

Expert Comment

by:exp2201
ID: 22955664
End of question
game-master,
Thanks for you response

0
 

Author Closing Comment

by:JDL129
ID: 31515325
Thanks for your help
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month19 days, 19 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question