Changes

Arrays and Functions in VB6

1,323 bytes added, 21:16, 6 February 2008
The following lines were added (+) and removed (-):
Option Explicit Option Explicit  Call RoutineA(varArray) Private Sub RoutineA(ByRef intArray() As Integer)  Dim obj As Variant  For Each obj In intArray    Form1.txtOut.text = Form1.txtOut.text & vbCrLf & obj  Next End Sub=== pass an Array back to the calling procedure === Private Function ReturnArray() As Variant  Dim MyArray(3) As Integer 'Declare a Static Integer Array of 4 elements  MyArray(0) = 1  MyArray(1) = 2  MyArray(2) = 3  MyArray(3) = 4  ReturnArray = MyArray 'Pass the array back as a return value End Function Accept an Array as an argument.  Private Sub cmdReturnArray_Click()  Dim retval As Variant  Dim obj  retval = ReturnArray 'Assign the return value to a Variant Variable  For Each obj In retval    Form1.Print obj  Next End Sub == Byte Arrays ===== Convert String to ANSI Byte Array ===Use the StrConv function with "vbFromUnicode" to convert a Visual Basic string to a byte array of ANSI characters. Dim company As String Dim b() As Byte company = "CHILKAT SOFTWARE" b = StrConv(company,vbFromUnicode)=== Convert Byte Array to String ===Use the StrConv function with "vbUnicode" to convert a byte array of ANSI characters to a string. Dim s As String Dim b(1 To 3) As Byte b(1) = Asc("A") b(2) = Asc("B") b(3) = Asc("C") s = StrConv(b, vbUnicode)
Bureaucrat, administrator
16,192
edits