Attribute VB_Name = "modGeneral" '============================================================================== ' ' File : General.bas ' Date : 31.03.1999 ' Version: 1.00 ' Author : Andreas Schmidt, lindner&partner ' '============================================================================== ' ' Diverse Hilfsmethoden ' '============================================================================== ' ' History: ' ' Date : 31.03.1999 ' Version: 1.00 ' Author : Andreas Schmidt, lindner&partner ' ' Erste Version. ' '============================================================================== Global Const DEZIMALTRENNER$ = "," Global Const TAUSENDERSTELLE$ = "." Global Const TAUSENDER_VERWENDEN = True Public Function stringToInt(sInput As String) As Integer Dim i As Integer Dim s As String ' Alle Punkte, Buchstaben etc. entfernen For i = 1 To Len(sInput) If IsNumeric(Mid$(sInput, i, 1)) Then s = s + Mid$(sInput, i, 1) End If Next i stringToInt = Val(s) End Function Public Function stringToLong(sInput As String) As Long Dim i As Integer Dim s As String ' Alle Punkte, Buchstaben etc. entfernen For i = 1 To Len(sInput) If IsNumeric(Mid$(sInput, i, 1)) Then s = s + Mid$(sInput, i, 1) End If Next i stringToLong = Val(s) End Function ' String-Wert in ein Double konvertieren. ' ' @param s String der Form "99.999,99" ' ' @return double-Wert ' Public Function stringToDouble(sInput As String) Dim i As Integer Dim nDecPos As Integer Dim s As String ' Alle Punkte, Buchstaben etc. bis auf den ' Dezimaltrenner entfernen For i = 1 To Len(sInput) If IsNumeric(Mid$(sInput, i, 1)) Or _ Mid$(sInput, i, 1) = DEZIMALTRENNER _ Then s = s + Mid$(sInput, i, 1) End If Next i ' Wir merken uns die Stelle, an der das Komma ' als Dezimaltrenner steht nDecPos = InStr(1, s, DEZIMALTRENNER) If nDecPos > 0 Then s = Left$(s, nDecPos - 1) + "." + Mid$(s, nDecPos + 1) End If stringToDouble = Val(s) End Function ' Integer-Value in einen String umwandeln. ' ' @param d Ausgangswert ' @param sFormat Format-String (siehe VB Format$()) ' Public Function intToString(i As Integer, sFormat As String) intToString = Format$(i, sFormat) End Function ' Long-Value in einen String umwandeln. ' ' @param d Ausgangswert ' @param sFormat Format-String (siehe VB Format$()) ' Public Function longToString(l As Long, sFormat As String) longToString = Format$(l, sFormat) End Function ' Double-Value in einen String umwandeln. ' ' @param d Ausgangswert ' @param sFormat Format-String (siehe VB Format$()) ' Public Function doubleToString(d As Double, sFormat As String) doubleToString = Format$(d, sFormat) End Function