Visual Basic Programming Code Examples Visual Basic > Applications VBA Code Examples Convert Long Integer to an equivalent Base32 String Convert Long Integer to an equivalent Base32 String ' Purpose: Converts an Integer to a Base32 representation ' Inputs: lngInp = Integer to be converted ' blnInp = Optional Boolean to indicate whether leading ' zeros are included in the result. Default is ' to omit the leading zeros. ' Returns: A string representation of the Base32 equivalent ' Comments: ' In order to avoid confusion with the numbers 1 and 0, the ' letters I and O are skipped. I also seem to recall that the ' letter Q and J should be similarly skipped. To do this, you ' must change the Select Case statement accordingly. Public Function ConvertToBase32( _ ByVal lngInp As Long, _ Optional ByVal blnInp As Boolean) As String Dim intCnt As Integer 'Integer counter for loop Dim strOut As String 'temp String holds result Dim intOut As Integer 'holds Integer part of formula strOut = "" 'initialize variable If IsMissing(blnInp) Then blnInp = False For intCnt = 6 To 0 Step -1 intOut = Int(lngInp / (32 ^ intCnt)) Select Case intOut Case Is = 0 If blnInp Then strOut = strOut & "0" Case Is < 10 'numbers between 0 and 9 strOut = strOut & Format(intOut, "0") Case Is < 18 'letters between A and H (skip I) strOut = strOut & Chr(intOut + 55) Case Is < 23 'letters between J and N (skip O) strOut = strOut & Chr(intOut + 56) Case Else 'letters between P and X strOut = strOut & Chr(intOut + 57) End Select lngInp = lngInp - intOut * (32 ^ intCnt) Next intCnt ConvertToBase32 = strOut End Function