Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Binary to Decimal

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,56198
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Binary to Decimal
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Binary to Decimal - 1/31/2008 5:49:45 AM   
  Parabellum


Posts: 222
Score: 0
Joined: 11/12/2006
From: UK
Status: offline
after a bit of searching around.... i was unable to find a builtin function or simapl way of converting a binary number to decimal... i found the hex function for hex to decimal, but nothing for binary.

I wote this little script to do the job.... but i was wondering if there is a simpler way i'm missing???

Option Explicit
Dim myVal, binVal, i, strLength, num, endVal
myVal = inputBox("Enter Binary Number")
BinToDec(myVal)
Function BinToDec(binVal)
  strLength = Len(binVal)
  For i=0 to strLength-1
      num = mid(binVal,strLength-i,1)
      endVal = endVal + num*(2^i)
  Next
  MsgBox endVal
End Function




< Message edited by Parabellum -- 1/31/2008 7:59:03 AM >
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Binary to Decimal Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts