Representing Numbers Graphically Demo

This demo illustrates the ConstructDigits function. Enter in any sort of string into the text box below... if you enter a number that contains no decimals and is greater than zero, you should see a graphical representation of that number!

Enter a Number:

Source Code for this Demo:

  Function ConstructDigits(iValue)
  'This function accepts a single parameter, iValue, and
  'returns HTML containing a series of images representing
  'a graphical image of the value in iValue

    'Start by ensuring iValue is a number
    If Not IsNumeric(iValue) then
      ConstructDigits = iValue & " IS NOT A NUMBER!"
      Exit Function
    End If

    'Can't show decimals!
    If InStr(1, iValue, ".") then
      ConstructDigits = "CANNOT CONTAIN DECIMALS!"
      Exit Function
    End If

    'Can't show negative numbers!
    If iValue < 0 then
      Exit Function
    End If

    Dim iLoop, strResults
    For iLoop = (Len(iValue) - 1) to 0 STEP -1
      strResults = strResults & "<img src=""/demos/digits/" & _
          Mid(CStr(iValue),Len(iValue) - iLoop,1) & ".gif"" border=0>"

    ConstructDigits = strResults
  End Function

  Dim iNumber
  iNumber = Request("iNumber")

  If Len(iNumber) > 0 then
    'Display iNumber
    Response.Write "<center>This page has been visited by:<br>" & _
                   ConstructDigits(iNumber) & _
                   "<br>visitors since September 28, 1998! <i>or whatever...</i></center>"
    Response.Write "<p><hr width=""75%""><p>"
  End If

[Return to the article] | [Download the ZIP of the images used in this demo]