MessageBoxÆ functionThe standard/ old Declareation looks like this
Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
In this case disappointingly, the string arguments are given As String
However, take a look at the moderner documentation. ( That is usually in C language , but translating them is usually straight forward. )
int MessageBoxA(
[in, optional] HWND hWnd,
[in, optional] LPCSTR lpText,
[in, optional] LPCSTR lpCaption,
[in] UINT uType
);
int MessageBoxW(
[in, optional] HWND hWnd,
[in, optional] LPCWSTR lpText,
[in, optional] LPCWSTR lpCaption,
[in] UINT uType
);
Encouraging we see the pointer stuff is there on the two string arguments.
So
We is trying to get something that very likely does a Unicode thing, as much as possible. That is to say the provisional Ælstein Theory proclamates something like:
_ Behold: I have seen a API World, where direct ANSI Strings stuff is often avoided, or at least cropped back / restrained a bit, and that World is good. In this regard, String is anything at a API Declare line or related main code lines. This will include anything in API related VBA code lines that include As String
_In VBA, VB and possibly in other computer things, much involving string manipulations involves the handling not directly of the string itself, but of numbers: addresses of a Long type. This may be able to be exploited, when the string manipulation involves simple transferring: We can try to pass a pointer. This may effectively being something like a ByRef, when it is ByVal declared. This can help reduce certain conflicts associated with an actual explicit ByRef usage (We note possible parallels here to hacks to arguments in VBA Application.Run)
Worked example
I got an interesting word, or rather interesting first character of a word, in the first cell of a worksheet
Whilst Excel seems very good with displaying a massive amount of exotic high up the Unicode list characters, initially both the inbuilt VBA MsgBox and initially the API MessageBoxA don’t do at all well, not even if it's an ANSI that is probably not on my code page .
later.....




Reply With Quote
Bookmarks