■ 16진수 문자열 → 2진수 문자열로 구하는 방법을 보여준다.
▶ 예제 코드 (VB)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
Public Function GetBinaryCode(ByVal strHexadecimalCode As String) As String Dim nHexadecimalStringLength As Integer Dim nTemporaryNumber As Integer Dim strResult As String Dim I As Integer Dim J As Integer nHexadecimalCodeLength = Len(strHexadecimalCode) For I = 1 To nHexadecimalCodeLength nTemporaryNumber = CInt("&H" & Mid(strHexadecimalCode, I, 1)) For J = 3 To 0 Step -1 If nTemporaryNumber >= 2 ^ J Then strResult = strResult & "1" nTemporaryNumber = nTemporaryNumber - 2 ^ J Else strResult = strResult & "0" End If Next J Next I GetBinaryCode = strResult End Function |