From VB6 to C#
-
Hi everyone. I have got some VB6 code i need to translate to C#, but i really cant understand the VB code. The program is something that communicates with a serial dervice. I do not know how much of the code I need to get translated, so it is possible that I will post more code later. Until now i've got this code: Private Sub Command1_Click() Dim CheckSum As Byte, x, Tid MSComm1.Settings = "1200,N,8,1" Buffer = "GET" + vbCr CheckAndSum Buffer ' add Checksum and Length of string Buffer = Buffer + SumStr 'For x = 1 To Len(Buffer) ' Tid = Timer ' Do ' DoEvents ' Loop Until (Timer - Tid > 0.01) ' MSComm1.Output = Mid(Buffer, x, 1) 'Next x MSComm1.Output = Buffer End Sub This should write some code to the Serial Port. I have already got the code for creating the checksum. When my device receives the GET command with vbCr (Carridge return), the checksum and the string Length, it should return 10 characters an example could be c=02345"Carrigde return"Checksum1Checksum2 I do not think you need more code that i pasted to do this. But I am not sure.. It would really be a great help if you could help me with this..
-
Hi everyone. I have got some VB6 code i need to translate to C#, but i really cant understand the VB code. The program is something that communicates with a serial dervice. I do not know how much of the code I need to get translated, so it is possible that I will post more code later. Until now i've got this code: Private Sub Command1_Click() Dim CheckSum As Byte, x, Tid MSComm1.Settings = "1200,N,8,1" Buffer = "GET" + vbCr CheckAndSum Buffer ' add Checksum and Length of string Buffer = Buffer + SumStr 'For x = 1 To Len(Buffer) ' Tid = Timer ' Do ' DoEvents ' Loop Until (Timer - Tid > 0.01) ' MSComm1.Output = Mid(Buffer, x, 1) 'Next x MSComm1.Output = Buffer End Sub This should write some code to the Serial Port. I have already got the code for creating the checksum. When my device receives the GET command with vbCr (Carridge return), the checksum and the string Length, it should return 10 characters an example could be c=02345"Carrigde return"Checksum1Checksum2 I do not think you need more code that i pasted to do this. But I am not sure.. It would really be a great help if you could help me with this..
-
Hi everyone. I have got some VB6 code i need to translate to C#, but i really cant understand the VB code. The program is something that communicates with a serial dervice. I do not know how much of the code I need to get translated, so it is possible that I will post more code later. Until now i've got this code: Private Sub Command1_Click() Dim CheckSum As Byte, x, Tid MSComm1.Settings = "1200,N,8,1" Buffer = "GET" + vbCr CheckAndSum Buffer ' add Checksum and Length of string Buffer = Buffer + SumStr 'For x = 1 To Len(Buffer) ' Tid = Timer ' Do ' DoEvents ' Loop Until (Timer - Tid > 0.01) ' MSComm1.Output = Mid(Buffer, x, 1) 'Next x MSComm1.Output = Buffer End Sub This should write some code to the Serial Port. I have already got the code for creating the checksum. When my device receives the GET command with vbCr (Carridge return), the checksum and the string Length, it should return 10 characters an example could be c=02345"Carrigde return"Checksum1Checksum2 I do not think you need more code that i pasted to do this. But I am not sure.. It would really be a great help if you could help me with this..
Wow, one of the reasons I am out of VB6.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway -
Wow, one of the reasons I am out of VB6.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest HemingwayEnnis Ray Lynch, Jr. wrote:
one of the reasons I am out of VB6
One of the reasons I never adopted it in my shop :-\
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
-
Maybe this will help[^]
-
Hi everyone. I have got some VB6 code i need to translate to C#, but i really cant understand the VB code. The program is something that communicates with a serial dervice. I do not know how much of the code I need to get translated, so it is possible that I will post more code later. Until now i've got this code: Private Sub Command1_Click() Dim CheckSum As Byte, x, Tid MSComm1.Settings = "1200,N,8,1" Buffer = "GET" + vbCr CheckAndSum Buffer ' add Checksum and Length of string Buffer = Buffer + SumStr 'For x = 1 To Len(Buffer) ' Tid = Timer ' Do ' DoEvents ' Loop Until (Timer - Tid > 0.01) ' MSComm1.Output = Mid(Buffer, x, 1) 'Next x MSComm1.Output = Buffer End Sub This should write some code to the Serial Port. I have already got the code for creating the checksum. When my device receives the GET command with vbCr (Carridge return), the checksum and the string Length, it should return 10 characters an example could be c=02345"Carrigde return"Checksum1Checksum2 I do not think you need more code that i pasted to do this. But I am not sure.. It would really be a great help if you could help me with this..
haolan wrote:
Private Sub Command1_Click() Dim CheckSum As Byte, x, Tid MSComm1.Settings = "1200,N,8,1" Buffer = "GET" + vbCr CheckAndSum Buffer ' add Checksum and Length of string Buffer = Buffer + SumStr 'For x = 1 To Len(Buffer) ' Tid = Timer ' Do ' DoEvents ' Loop Until (Timer - Tid > 0.01) ' MSComm1.Output = Mid(Buffer, x, 1) 'Next x MSComm1.Output = Buffer End Sub
A few questions... Which serial port? How do you know this does not work? Where is code to listen for the result your program is expecting? What is the specification of the device that needs this input? Maybe the port parameters do not match up?