Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. From VB6 to C#

From VB6 to C#

Scheduled Pinned Locked Moved C#
csharphelptutorial
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haolan
    wrote on last edited by
    #1

    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..

    L E C 3 Replies Last reply
    0
    • H haolan

      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..

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Maybe this will help[^]

      H 1 Reply Last reply
      0
      • H haolan

        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..

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • E Ennis Ray Lynch Jr

          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

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Ennis 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

          1 Reply Last reply
          0
          • L led mike

            Maybe this will help[^]

            H Offline
            H Offline
            haolan
            wrote on last edited by
            #5

            I already had looked at MSDN.. I have tried make some code.. But no matter what i do it doesn't seem to work..

            1 Reply Last reply
            0
            • H haolan

              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..

              C Offline
              C Offline
              ChandraRam
              wrote on last edited by
              #6

              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?

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups