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. Convert Variant in VB to C#

Convert Variant in VB to C#

Scheduled Pinned Locked Moved C#
csharpdatabasehelp
3 Posts 2 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.
  • K Offline
    K Offline
    klaydze
    wrote on last edited by
    #1

    Hi, I'm just starting to convert my vb6.0 program to c#.net and I have a function in vb6.0 below: Anyone can help me to translate this in c#.net.

    Public Function GetData(SQL As String) As Variant
    Dim RST As ADODB.Recordset
    Set RST = Conn.Execute(SQL)
    With RST
    If .State = adStateOpen Then
    If Not .EOF Then
    If Not IsNull(RST(0)) Then
    Select Case RST(0).Type
    Case adVarChar
    GetData = Trim(RST(0))
    Case Else
    GetData = RST(0)
    End Select
    Else
    Select Case RST(0).Type
    Case adBoolean
    GetData = False
    Case adVarChar
    GetData = ""
    Case adDouble, adInteger
    GetData = 0
    Case adDate, adDBTimeStamp
    GetData = InvalidDate
    End Select
    End If
    Else
    Select Case RST(0).Type
    Case adBoolean
    GetData = False
    Case adVarChar
    GetData = ""
    Case adDouble, adInteger
    GetData = 0
    Case adDate, adDBTimeStamp
    GetData = InvalidDate
    End Select
    End If
    Else
    Select Case RST(0).Type
    Case adBoolean
    GetData = False
    Case adVarChar
    GetData = ""
    Case adDouble, adInteger
    GetData = 0
    Case adDate, adDBTimeStamp
    GetData = InvalidDate
    End Select
    End If
    End With
    Set RST = Nothing
    End Function

    THANKS AND REGARDS klaydze

    if(you type your code here) { Messagebox.Show("You help me a lot!"); } else { You help me = null; }

    L 1 Reply Last reply
    0
    • K klaydze

      Hi, I'm just starting to convert my vb6.0 program to c#.net and I have a function in vb6.0 below: Anyone can help me to translate this in c#.net.

      Public Function GetData(SQL As String) As Variant
      Dim RST As ADODB.Recordset
      Set RST = Conn.Execute(SQL)
      With RST
      If .State = adStateOpen Then
      If Not .EOF Then
      If Not IsNull(RST(0)) Then
      Select Case RST(0).Type
      Case adVarChar
      GetData = Trim(RST(0))
      Case Else
      GetData = RST(0)
      End Select
      Else
      Select Case RST(0).Type
      Case adBoolean
      GetData = False
      Case adVarChar
      GetData = ""
      Case adDouble, adInteger
      GetData = 0
      Case adDate, adDBTimeStamp
      GetData = InvalidDate
      End Select
      End If
      Else
      Select Case RST(0).Type
      Case adBoolean
      GetData = False
      Case adVarChar
      GetData = ""
      Case adDouble, adInteger
      GetData = 0
      Case adDate, adDBTimeStamp
      GetData = InvalidDate
      End Select
      End If
      Else
      Select Case RST(0).Type
      Case adBoolean
      GetData = False
      Case adVarChar
      GetData = ""
      Case adDouble, adInteger
      GetData = 0
      Case adDate, adDBTimeStamp
      GetData = InvalidDate
      End Select
      End If
      End With
      Set RST = Nothing
      End Function

      THANKS AND REGARDS klaydze

      if(you type your code here) { Messagebox.Show("You help me a lot!"); } else { You help me = null; }

      L Offline
      L Offline
      Le centriste
      wrote on last edited by
      #2

      Do you even know C#?

      K 1 Reply Last reply
      0
      • L Le centriste

        Do you even know C#?

        K Offline
        K Offline
        klaydze
        wrote on last edited by
        #3

        Le Centriste wrote:

        Do you even know C#?

        Yeah but not that good as in VB6.

        if(you type your code here) { Messagebox.Show("You help me a lot!"); } else { You help me = null; }

        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