2019 VBA reference - equivalents for Autoit, C++ and Java function and keywords

Author: Jeffrey Paesch

This page is started on March 10, 2019. The idea is to provide techniques, function to equivalents well know programming language functions and or statements.
You will enjoy this page, especially if you are the guy that translate code to another code Language,

==========================================================
Return x 
Description: exit function and return a value (java, autoit, and more)
Solution:  functionname = x: exit function (on the same line)
Example:
.    function (arg1,....)
.        if arg1 = "" then myfunction = -1: exit function
.        .......
.        ....
.    end function
==========================================================
void mysub( const int i );.
Description: passing const variable (as of C++) to VBA function. Link with detailed description
Solution: create a local (scope) variable within your function and capture the function byref variables
Example:
.    function (arg1,const_arg1 as integer, const_arg2 as boolean)
.        Dim arg1as integer, arg2 as boolean
.        arg1 = const_arg1,
.        arg2 = const_arg2
.        ' work from here with the local variables arg1 and arg2,
.        .......
.        ....
.    end function
==========================================================
more to come


2019 VBA Clear Inmmediate window


Author Jeffrey Paesch

There are many post about clearing the immediate window. However none of them seems to work or at least work as I expected. For instance many of the pages suggest flush the immediate. To flush your immediate window in VBA you can use the following sub.

Sub VBE_immediate_flush()
    Debug.Print String(100, vbCr)
End Sub

When it comes to clear your window, the following statement  will help you:
Application.SendKeys "^g ^a {bs}".
However, the above statement has limitation, It can not be run while you are running your codes. Immediate windows can be cleared only in the reset (stop) mode.
Pasting the above statement at the beginning of your statements will not have a desirable result. Your immediate window will remain empty, although you unfocused the immediate window with "Doevents" or Application.SendKeys "{F7}" statement.
Therefore, the best solution to cleare the immediate window is with the following sub:

Sub VBE_immediate_clear()
    get_win = Application.VBE.ActiveWindow.Caption
    cmpnts1 = Mid(get_win, 1, InStr(get_win, "(") - 2)
    Application.SendKeys "^g ^a {bs}"
    Stop
    Application.SendKeys "{F7}"
    Set Application.VBE.ActiveCodePane = _
    ThisWorkbook.VBProject.VBComponents(cmpnts1).CodeModule.CodePane
End Sub

Cons
This sub enter the reset (stop) mode in order to give the immediate windows to clear.

pros
it clear the immediate windows for real
The sub can be call at the beginning of your statements.
The sub will later activate and focus the captured VBE window after the immediate cleaning.


Conclusion
I hope this code will save you lot of headache on research