Getting the Byte Value of a String
Getting the Byte Value of a String
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
The following example converts the string GUID into a hex GUID.
Visual Basic
'////////////////////////////////////////////////////////////////////// ' Function: getByteValue() ' Purpose: The following example converts the string guid into a hex guid. ' ' ' Input: szStr: String to process ' ' Output: getByteValue: Byte value of string ' ' Note: In order for this example to function correctly, it may be necessary to include ' references to the following libraries: Active DS Type Library, Microsoft CDO for ' Exchange Management Library, Microsoft Cluster Service Automation Classes, ' Microsoft CDO for Windows 2000 Library. '////////////////////////////////////////////////////////////////////// Function getByteValue(szStr As String) As Byte Dim szChar As String Dim bVal1 As Byte Dim bVal2 As Byte ' For simplicity so you can see the logic, each character is handled ' individually. szChar = Mid(szStr, 1, 1) ' Convert from a string value to hex value. Select Case szChar Case "0" bVal1 = &H0 Case "1" bVal1 = &H1 Case "2" bVal1 = &H2 Case "3" bVal1 = &H3 Case "4" bVal1 = &H4 Case "5" bVal1 = &H5 Case "6" bVal1 = &H6 Case "7" bVal1 = &H7 Case "8" bVal1 = &H8 Case "9" bVal1 = &H9 Case "A" bVal1 = &HA Case "B" bVal1 = &HB Case "C" bVal1 = &HC Case "D" bVal1 = &HD Case "E" bVal1 = &HE Case "F" bVal1 = &HF End Select ' Shift over. bVal1 = bVal1 * &H10 ' get the second character. szChar = Mid(szStr, 2, 1) ' Convert from a string value to hex value. Select Case szChar Case "0" bVal2 = &H0 Case "1" bVal2 = &H1 Case "2" bVal2 = &H2 Case "3" bVal2 = &H3 Case "4" bVal2 = &H4 Case "5" bVal2 = &H5 Case "6" bVal2 = &H6 Case "7" bVal2 = &H7 Case "8" bVal2 = &H8 Case "9" bVal2 = &H9 Case "A" bVal2 = &HA Case "B" bVal2 = &HB Case "C" bVal2 = &HC Case "D" bVal2 = &HD Case "E" bVal2 = &HE Case "F" bVal2 = &HF End Select getByteValue = bVal1 + bVal2 End Function
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.