|
Kennen Sie (noch) die in vielen Basic-Dialekten verfügbaren Funktionen wie MKI und CVI zum Umgang mit der Byte-weisen Darstellung von Zahlen in Form von Strings? Wenn Sie diese Funktionen in Visual Basic vermissen sollten - hier sind die entsprechenden Paare MKI/CVI für Integer-, MKL/CVL für Long-, MKS/CVS für Single- und MKD/CVD für Double-Zahlen.
Private Type IntType
I As Integer
End Type
Private Type LngType
L As Long
End Type
Private Type SngType
S As Single
End Type
Private Type DblType
D As Double
End Type
Private Type StrType
S As String * 8
End Type
Public Function CVI(Value As String) As Integer
Dim nStr As StrType
Dim nInt As IntType
nStr.S = StrConv(Left$(Value, 2), vbFromUnicode)
LSet nInt = nStr
CVI = nInt.I
End Function
Public Function MKI(ByVal Value As Integer) As String
Dim nStr As StrType
Dim nInt As IntType
nInt.I = Value
LSet nStr = nInt
MKI = Left(StrConv(nStr.S, vbUnicode), 2)
End Function
Public Function CVL(Value As String) As Long
Dim nStr As StrType
Dim nLng As LngType
nStr.S = StrConv(Left$(Value, 4), vbFromUnicode)
LSet nLng = nStr
CVL = nLng.L
End Function
Public Function MKL(ByVal Value As Long) As String
Dim nStr As StrType
Dim nLng As LngType
nLng.L = Value
LSet nStr = nLng
MKL = Left(StrConv(nStr.S, vbUnicode), 4)
End Function
Public Function CVS(Value As String) As Single
Dim nStr As StrType
Dim nSng As SngType
nStr.S = StrConv(Left$(Value, 4), vbFromUnicode)
LSet nSng = nStr
CVS = nSng.S
End Function
Public Function MKS(ByVal Value As Single) As String
Dim nStr As StrType
Dim nSng As SngType
nSng.S = Value
LSet nStr = nSng
MKS = Left(StrConv(nStr.S, vbUnicode), 4)
End Function
Public Function CVD(Value As String) As Double
Dim nStr As StrType
Dim nDbl As DblType
nStr.S = StrConv(Left$(Value, 8), vbFromUnicode)
LSet nDbl = nStr
CVD = nDbl.D
End Function
Public Function MKD(ByVal Value As Double) As String
Dim nStr As StrType
Dim nDbl As DblType
nDbl.D = Value
LSet nStr = nDbl
MKD = Left(StrConv(nStr.S, vbUnicode), 8)
End Function
|