VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "StringClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Private BinaryDigits(16) As String
Private NDigits(20) As String
Private NTens(10) As String

Private Sub Class_Initialize()
BinaryDigits(0) = "0000"
BinaryDigits(1) = "0001"
BinaryDigits(2) = "0010"
BinaryDigits(3) = "0011"
BinaryDigits(4) = "0100"
BinaryDigits(5) = "0101"
BinaryDigits(6) = "0110"
BinaryDigits(7) = "0111"
BinaryDigits(8) = "1000"
BinaryDigits(9) = "1001"
BinaryDigits(10) = "1010"
BinaryDigits(11) = "1011"
BinaryDigits(12) = "1100"
BinaryDigits(13) = "1101"
BinaryDigits(14) = "1110"
BinaryDigits(15) = "1111"

NDigits(1) = "one"
NDigits(2) = "two"
NDigits(3) = "three"
NDigits(4) = "four"
NDigits(5) = "five"
NDigits(6) = "six"
NDigits(7) = "seven"
NDigits(8) = "eight"
NDigits(9) = "nine"
NDigits(10) = "ten"
NDigits(11) = "eleven"
NDigits(12) = "twelve"
NDigits(13) = "thirteen"
NDigits(14) = "fourteen"
NDigits(15) = "fifteen"
NDigits(16) = "sixteen"
NDigits(17) = "seventeen"
NDigits(18) = "eighteen"
NDigits(19) = "nineteen"

NTens(2) = "twenty"
NTens(3) = "thirty"
NTens(4) = "forty"
NTens(5) = "fifty"
NTens(6) = "sixty"
NTens(7) = "seventy"
NTens(8) = "eighty"
NTens(9) = "ninety"
End Sub


Private Function ReadSingle(Number) As String
    If Number > 0 And Number < 20 Then
        ReadSingle = NDigits(Number)
    Else
        ReadSingle = "*****"
    End If
End Function

Private Function ReadTenths(Number)
    tnumber = Int(Number / 10)
    If tnumber > 1 And tnumber < 10 Then
        ReadTenths = NTens(tnumber)
    Else
        ReadTenths = "*****"
    End If
End Function

'This is the routine to read numbers
Public Function Number2String(Number)
Dim tenth As Integer
Dim leftover As Integer
Dim hundred As Integer
Dim thousand As Integer
        
    If Number < 20 Then         'Reads unique numbers
        NumString = ReadSingle(Number)
    ElseIf Number < 100 Then    'Reads numbers less than 100
        tenth = Fix(Number / 10)
        NumString = ReadTenths(tenth * 10)
        leftover = Number - (tenth * 10)
        If leftover > 0 Then
            NumString = NumString & " " & ReadSingle(leftover)
        End If
    ElseIf Number < 1000 Then   'Reads numbers between 100 and 999
        hundred = Fix(Number / 100)
        NumString = ReadSingle(hundred) & " hundred"
        leftover = Number - (hundred * 100)
        If leftover > 0 Then
            tenth = Fix(leftover / 10)
            If tenth > 0 Then NumString = NumString & " " & ReadTenths(tenth * 10)
            leftover = Number - (hundred * 100) - (tenth * 10)
            If leftover > 0 Then
                NumString = NumString & " " & ReadSingle(leftover)
            End If
        End If
    Else                        'Reads number between 1000 and 9999
        thousand = Fix(Number / 1000)
        NumString = ReadSingle(thousand) & " thousand"
        leftover = Number - (thousand * 1000)
        If leftover > 0 Then
            hundred = Fix(leftover / 100)
            If hundred > 0 Then
                NumString = NumString & " " & ReadSingle(hundred) & " hundred"
            End If
            leftover = Number - (thousand * 1000) - (hundred * 100)
            If leftover > 0 Then
                tenth = Fix(leftover / 10)
                If tenth > 0 Then
                    NumString = NumString & " " & ReadTenths(tenth * 10)
                End If
                leftover = Number - (thousand * 1000) - (hundred * 100) - (tenth * 10)
                If leftover > 0 Then
                    NumString = NumString & " " & ReadSingle(leftover)
                End If
            End If
        End If
    End If
    Number2String = NumString
End Function

Public Function LowerCaps(str As String) As String
Dim newWord As String, newStr As String
Dim tempStr As String
Dim WDelimiter As Integer

    tempStr = Trim(str)
    WDelimiter = InStr(tempStr, " ")
    While WDelimiter > 0
        newWord = Left(tempStr, WDelimiter)
        tempStr = Right(tempStr, Len(tempStr) - WDelimiter)
        newStr = newStr & UCase(Left(newWord, 1)) & Mid(newWord, 2, Len(newWord) - 1)
        WDelimiter = InStr(tempStr, " ")
    Wend
    newWord = tempStr
    newStr = newStr & UCase(Left(newWord, 1)) & Mid(newWord, 2, Len(newWord) - 1)
    LowerCaps = newStr
End Function

Public Function Integer2Binary(ByVal Number As Long) As String
    HexNum = Hex(Number)
    For i = 1 To Len(HexNum)
        BinNum = BinNum & BinaryDigits("&H" & Mid(HexNum, i, 1))
    Next
    Integer2Binary = BinNum
End Function



