terça-feira, 15 de abril de 2008

IsBlank()

Função para verificar se uma variável está vazia ou não.

Function IsBlank(ByRef TempVar)
    IsBlank = False

    Select Case VarType(TempVar)    
        'Vazia & Nula
        Case 0, 1
            IsBlank = True
        
        'String
        Case 8
            If Len(TempVar) = 0 Then
                IsBlank = True
            End If
            
        'Objeto
        Case 9
            tmpType = TypeName(TempVar)
            If (tmpType = "Nothing") Or (tmpType = "Empty") Then
                IsBlank = True
            End If
        
        'Array
        Case 8192, 8204, 8209
            'Ele tem, pelo menos, um elemento?
            If UBound(TempVar) = -1 Then
                IsBlank = True
            End If
    End Select
End Function

Nenhum comentário: