You are on page 1of 2

Program-1

Public Function DecToBin(Decimalvalue As Long, Optional Bits As Integer = 8) As String

Dim i As Integer

Do While Decimalvalue > (2 ^ Bits) - 1

Bits = Bits = 8

Loop

DecToBin = vbNullString

For i = 0 To (Bits - 1)

DecToBin = CStr((Decimalvalue And 2 ^ i) / 2 ^ i) & DecToBin

Next i

End Function

Private Sub Command1_Click()

Text2.Text = DecToBin(Val(Text1.Text))

Text3.Text = Hex$(Text1.Text)

Text4.Text = Oct$(Text1.Text)

End Sub

You might also like