Yes, with-out reading you code I already know what you want to say here (I was thinking about mentioning it also but then thought better to drop it - it didn't concern the question and the point was covered as far as speed - the only difference that was needed to be pointed out here). But seeing's how you did it anyways then "cheers" - some who read your and my comments may profit from them.
When you declare a string variable and, with-out initalizing it, it will hold a Null and can be passed as such, it gets passed as a NULL and not as a string variable with zero length.
To see this declare a variable as a string (Dim s As String) and use the StrPtr function:
Debug.Print StrPtr(s) and then do the same after assigning the variable ""
This means that if I declare a variable as String - I can pass it to a DLL function that requires it - but once I assign a value to the string - even "" - it will not work anymore.
To advoid mis-understandings - or errors I should say - it is best to pass a variable set to vbNullString, or just the vbNullString constant itself.
Some DLL procedures possibly expect a string or a Null value as argment. When a Null pointer to a string needs to be passed, then the argument needs to be declared As String and the constant vbNullstring needs assigned, or just the constant itself (VB)
Passing a string with the length of Null ("" ) doesn't work because the pointer to a Null String gets passed whose value itself isn't Null. Therefore a argumkent with a Real Null value needs to be passed - and that is done by passing vbNullString or passing a unassigned string.......
I would say let's close out this chapter - the points have been made and past mis-understandings have been cleared up - I hope - and possibly new ones created - and I hope the real message in the post hasn't gone under.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.