Typ-Konvertierungen

CType

  • wandelt einen Typ in einen angegebenen anderen Typ um
  • ' wandelt die Zahl 123.45 in einen String um
    Dim n As Decimal = 123.45
    Dim s As String
    s = CType(n, String)
    

spezielle Typumwandlungen, welche immer einen übergebenes Objekt in den festgelegten Typ wandeln

  • CBool – Bool
  • Dim bBoolean As Boolean
    bBoolean = CBool(0) ' False
    bBoolean = CBool(1) ' True
    
  • CByte – Byte
  • CChar – Char
  • CDate – Datumsangaben
  • CDbl – Double
  • Dim i1 As Integer = 56
    Dim d As Double = CDbl(i1) / 3.14
    
  • CDec – Decimal
  • Dim i1 As Integer = 5000
    Dim d As Decimal = CDec(i1) / 34)
    
  • CInt – Integer
  • CLng – Long
  • Dim i1 As Integer = 1005
    Dim i2 As Integer = 2100
    Dim l As Long = CLng(i1) * CLng(i2)
    
  • CObj – Object
  • CSByte – SByte
  • CShort – Short
  • CSng – Single
  • Dim i1 As Integer = 56
    Dim z As Single = CSng(i1) / 3.4
    
  • CStr – String
  • CUInt – unsigned Integer
  • CULng – unsigned Long
  • CUShort – unsigned Short