SAMPLE: ARRAYCONVERT.EXE Variant Conversion Functions (250344)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 4.0
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 4.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q250344

SUMMARY

ArrayConvert.exe is a sample that is used to convert Variants of one type to Variants of another type. For example, if you are using Visual Basic Script (VBScript), these conversion functions aid you in converting a Variant that contains an Octet string to a Variant that contains a Hex string.

MORE INFORMATION

The following file is available for download from the Microsoft Download Center:
The ArrayConvert.exe file contains the following files:

ADS.vbp747 bytes
ADS.vbw35 bytes
ArrayConvert.cls3017 bytes
ArrayConvertTest.bas1205 bytes
ArrayConvertTest.vbg67 bytes
ArrayConvertTest.vbp884 bytes
ArrayConvertTest.vbw31 bytes
ADS.dll24,576 bytes
ADs.exp996 bytes
ADs.lib2536 bytes
AdsConvert.vbg73 bytes


Release Date: Apr-13-2000

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. The five functions that are in this sample are:
  1. CStrArray - Use this function to convert a Variant Array of strings to a Variant Array of Variants containing strings. This allows VBScript to access multi-valued string attributes returned in ADO recordsets.

    CvOctetStr2vHexStr - Use this function to convert a Variant Array of bytes to a Variant containing an ASCII-encoded Hex string. This allows VBScript to translate an ADSTYPE_OCTETSTRING Variant into a string of ASCII characters 0-9 A-F.

    CvHexStr2vOctetStr -Use this function to convert a Variant containing an ASCII-encoded Hex string to a Variant Array of bytes. This allows VBScript to create Variants for ADSTYPE_OCTETSTRING from strings of ASCII characters 0-9 A-F.

    CvOctetStr2vStr - Use this function to convert a Variant Array of bytes to a Variant containing an ASCII string. This allows VBScript to translate an ADSTYPE_OCTETSTRING Variant into a string of ASCII characters.

    CvStr2vOctetStr - Use this function to convert a Variant containing a string to a Variant Array of bytes. This allows VBScript to create Variants for ADSTYPE_OCTETSTRING from strings of ASCII characters.
  2. CvOctetStr2vHexStr - Use this function to convert a Variant Array of bytes to a Variant containing an ASCII-encoded Hex string. This allows VBScript to translate an ADSTYPE_OCTETSTRING Variant into a string of ASCII characters 0-9 A-F.

    CvHexStr2vOctetStr -Use this function to convert a Variant containing an ASCII-encoded Hex string to a Variant Array of bytes. This allows VBScript to create Variants for ADSTYPE_OCTETSTRING from strings of ASCII characters 0-9 A-F.

    CvOctetStr2vStr - Use this function to convert a Variant Array of bytes to a Variant containing an ASCII string. This allows VBScript to translate an ADSTYPE_OCTETSTRING Variant into a string of ASCII characters.

    CvStr2vOctetStr - Use this function to convert a Variant containing a string to a Variant Array of bytes. This allows VBScript to create Variants for ADSTYPE_OCTETSTRING from strings of ASCII characters.
  3. CvHexStr2vOctetStr -Use this function to convert a Variant containing an ASCII-encoded Hex string to a Variant Array of bytes. This allows VBScript to create Variants for ADSTYPE_OCTETSTRING from strings of ASCII characters 0-9 A-F.

    CvOctetStr2vStr - Use this function to convert a Variant Array of bytes to a Variant containing an ASCII string. This allows VBScript to translate an ADSTYPE_OCTETSTRING Variant into a string of ASCII characters.

    CvStr2vOctetStr - Use this function to convert a Variant containing a string to a Variant Array of bytes. This allows VBScript to create Variants for ADSTYPE_OCTETSTRING from strings of ASCII characters.
  4. CvOctetStr2vStr - Use this function to convert a Variant Array of bytes to a Variant containing an ASCII string. This allows VBScript to translate an ADSTYPE_OCTETSTRING Variant into a string of ASCII characters.

    CvStr2vOctetStr - Use this function to convert a Variant containing a string to a Variant Array of bytes. This allows VBScript to create Variants for ADSTYPE_OCTETSTRING from strings of ASCII characters.
  5. CvStr2vOctetStr - Use this function to convert a Variant containing a string to a Variant Array of bytes. This allows VBScript to create Variants for ADSTYPE_OCTETSTRING from strings of ASCII characters.
To use the sample, double-click on the self-extracting executable file ArrayConvert.exe. Using Visual Basic, open the ArrayConvertTest.vbg file. Once the project is open you can run the test program that demonstrates how to use the conversion functions.

To use the functions from VBScript, you can register the the Ads.Dll file by doing Regsvr32 Ads.dll and then calling the functions from VBScript.

The following is an example of using the CStrArray function in a VBScript to convert and display the members of Distribution lists in an Exchange Organization:
 
Set cnvt = CreateObject("ADs.ArrayConvert")
Set conn = CreateObject("ADODB.connection")
conn.provider = "ADSDSOObject"
conn.open ""
Set rs = conn.execute( _
    "<LDAP://Server/o=organization/ou=site/cn=recipients>;(objectClass=groupOfNames);ADsPath,member;onelevel")
       
While Not rs.EOF
    v1 = cnvt.CStrArray(rs.fields("member").Value)
    For Each v2 In v1
	msgbox v2
    Next

    rs.movenext
Wend
				

Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbfile kbhowto kbprogramming kbsample KB250344