Microsoft Small Basic

Program Listing:
Embed this in your website
start:
TextWindow.Title = "Binary to Decimal To Binary Converter [Amir Rke]"
TextWindow.Write("Enter Your Choice: [1 for binary to decimal] Or [2 four decimal to binary] ")
choice = TextWindow.ReadNumber()
If choice = 1 Then
  Goto start1
ElseIf choice = 2 Then
  Goto start2
EndIf
start1:
TextWindow.Write("Convert Binary To Decimal..."+Text.GetCharacter(10)+"Enter Binary Value : ")
binary = TextWindow.ReadNumber()
For bit_Count = 1 To Text.GetLength(binary)
  binaryNum = binaryNum + Text.GetSubText(binary,Text.GetLength(binary)-bit_Count+1,1)*Math.Power(2,bit_Count-1)
EndFor
TextWindow.ForegroundColor = "red"
TextWindow.Write("Decimal form : "+binaryNum+Text.GetCharacter(10))
TextWindow.ForegroundColor = "white"
binaryNum = ""
Goto start
start2:
count = 0
Bits = ""
TextWindow.Write(Text.GetCharacter(10)+"Convert Decimal To Binary..."+Text.GetCharacter(10)+"Enter Decimal Value : ")
N = TextWindow.ReadNumber()
temp = N
While N > 0
  Bits[count] = Math.Remainder(N,2)
  N = Math.Floor(N / 2)
  count = count + 1
EndWhile
TextWindow.ForegroundColor = "Green"
TextWindow.Write("Binary Form ")
For i = Array.GetItemCount(Bits) To 0 step - 1
    TextWindow.Write(Bits[i])
  EndFor
  TextWindow.Write(Text.GetCharacter(10))
  TextWindow.ForegroundColor = "White"
Goto start
Copyright (c) Microsoft Corporation. All rights reserved.