Advertisement
hectah

binary to hex console

Sep 22nd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.70 KB | None | 0 0
  1.  Sub BinToDec()
  2.         denary = 0
  3.         length = binaryTxt.Text.Length
  4.         For x = 1 To length
  5.             length = length - 1
  6.             If binaryTxt.Text(length) = "1" Then
  7.                 denary = denary + (2 ^ (x - 1))
  8.             End If
  9.         Next
  10.     End Sub
  11.  
  12.     Sub DecToHex()
  13.         hexa = Hex(denary)
  14.         Console.WriteLine(hexa)
  15.  
  16.     End Sub
  17.     Sub HexToDec()
  18.         denary = CInt("&H" & hexTxt.Text)
  19.     End Sub
  20.     Sub DecToBin()
  21.         binary = Convert.ToString(denary, 2)
  22.         Console.WriteLine(binary)
  23.     End Sub
  24.     Sub BinToHex()
  25.         BinToDec()
  26.         DecToHex()
  27.     End Sub
  28.     Sub HexToBin()
  29.         HexToDec()
  30.         DecToBin()
  31.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement