VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This function will Trim an Array. It removes all empty strings and Null values from an Array and

by Joshua Carroll (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 25th September 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This function will "Trim" an Array. It removes all empty strings and Null values from an Array and returns.

API Declarations


'its just nice to know if it was helpful to someone else.

Rate This function will Trim an Array. It removes all empty strings and Null values from an Array and



    Dim tempArray As Variant, tempArrayCount As Integer
    tempArray = Array(tempArray)
    
    tempArrayCount = -1
    For x = 0 To UBound(varArray)
        If varArray(x) <> "" Then
            tempArrayCount = tempArrayCount + 1
        End If
    Next x
    
    ReDim tempArray(tempArrayCount)
    
    tempArrayCount = 0
    For x = 0 To UBound(varArray)
        If varArray(x) <> "" And Not varArray(x) = vbNull Then
            tempArray(tempArrayCount) = varArray(x)
            tempArrayCount = tempArrayCount + 1
        End If
    Next x
    
    varArray = tempArray
End Function

Download this snippet    Add to My Saved Code

This function will Trim an Array. It removes all empty strings and Null values from an Array and Comments

No comments have been posted about This function will Trim an Array. It removes all empty strings and Null values from an Array and . Why not be the first to post a comment about This function will Trim an Array. It removes all empty strings and Null values from an Array and .

Post your comment

Subject:
Message:
0/1000 characters