Skip to main content
NetworkAdminKB Logo

VBScript Library

Go Search
NetworkAdminKB.com
Knowledge Base
VBScript Library
Utilities
  
NetworkAdminKB.com > VBScript Library > Knowledge Base > Components > Math > Dec2Bin  

Dec2Bin

Article Content

'********************************************************************

'*

'* Function Dec2Bin

'*

'*   Author: NetworkAdminKB.com

'*  Created: 2004-11-22

'* Modified: 2004-11-22

'*

'* Purpose: Converts a decimal to a binary string.

'*

'* Input:   intAny    Any Integer

'*

'* Output:  Returns a string of the Binary (0,1) representation

'*            of the decimal number.

'*

'********************************************************************

Function Dec2Bin(ByVal intAny)

  'Version 1.0 2004-11-22

  strTemp = ""

  Do While intAny > 0

    If intAny Mod 2 > 0 Then

      strTemp = "1" & strTemp

    Else

      strTemp = "0" & strTemp

    End If

    intAny = Int(intAny / 2)

  Loop 'intAny > 0

  If Len(strTemp) = 0 Then

    strTemp = "0"

  End If 'Len(strTemp) = 0

  Dec2Bin = strTemp

End Function 'Dec2Bin

Keywords
Math Conversion 
Related Articles
 
Last modified at 1/12/2009 8:05 PM  by TEMPLATE\kbadmin 
 
 NetworkAdminKB.com
 Copyright © 2008 NetworkAdminKB.com, All rights reserved. Terms of Use | Contact US