Variant brain fart.

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
I've got a VB6 app that I'm updating, I have a call into a function that's supposed to return an array of strings to the caller. On return, I thought I'd check UBound(returnedArray) and populate a list box with the contents, if any. Turns out that if nothing was "returned", the Variant argument still gets set from Empty to a Variant/String(), but with no contained data. This causes UBound to throw an error.

I've tried IsArray and IsEmpty. I can't use IsNull because the called function returns a string array which can't be set to null. I've run out of ideas on what I could possibly use to test if there's valid data. VB6 isn't my strong suit... any ideas?

Edit: NM, I went and changed the called function to take a string array as a parameter and return a count. That'll suffice, and noone will be the wiser. Damn legacy apps.
 
Last edited:

TomGriffinII

Junior Member
Aug 14, 2009
9
0
0
you might try

DIM xVar as Variant

IF ISNULL(xVar) or ISEMPTY(xVAR) THEN
'Do your thing here for empty or null array
ELSE
'Do retro programming here
END IF

I think that is the correct syntax; examples are available with the MSDN reference materials included with Visual Studio 97 (vb 6, vc 5 etc).

IF xVar IS Empty Then
'empty
Else
'do your groove
End If
 
Last edited: