clsObjectProp is 0 length string, attribute.textstring wont accept this

clsObjectProp is 0 length string, attribute.textstring wont accept this

mdhutchinson
Advisor Advisor
278 Views
1 Reply
Message 1 of 2

clsObjectProp is 0 length string, attribute.textstring wont accept this

mdhutchinson
Advisor
Advisor
My clsObject ContNumItem.Mark property is a String data type... why would this pop a Invalid Input -2145386493 error when ContNumItem.Mark is a zero length string.
varAtts(incAtt).TextString = ContNumItem.Mark

I ended up having to use:
[code]
If ContNumItem.ProductCode = "" Then
varAtts(incAtt).TextString = ""
Else
varAtts(incAtt).TextString = ContNumItem.ProductCode
End If
[/code]

It also will not accept vbNullString which VBA reads as "". Message was edited by: hutch
0 Likes
279 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
It sounds like Mark may be a null string instead of an empty string.
They're not the same even though VBA will generally tell you that
they are. An empty string points to a valid memory address that
contains a zero-length VB string. A null string (vbNullString) points
to "memory" at location zero.

Dim Mark As String ' gets you a null string.
Mark = "" ' gets you an empty string

If you want imperceptibly faster code, try:

If (0 = Len(ContNumItem.ProductCode)) Then

If you want less code, lose the block-If:

varAtts(incAtt).TextString = ContNumItem.ProductCode & ""
0 Likes