Wednesday, June 17, 2015

What is the difference between ByVal and ByRef?

Xiaoyun Li MSFT answers ---

When you write a subroutine or function, you can pass variables from your main code to that subroutine or function.

If you want to pass the value of the variable, use the ByVal syntax. By passing the value of the variable instead of a reference to the variable, any changes to the variable made by code in the subroutine or function will not be passed back to the main code. This is the default passing mechanism when you don’t decorate the parameters by using ByVal or ByRef.

If you want to change the value of the variable in the subroutine or function and pass the revised value back to the main code, use the ByRef syntax. This passes the reference to the variable and allows its value to be changed and passed back to the main code.

For more information about passing Arguments by Value and by Reference, please refer to MSDN document:

C# --- 

.NET Coding: Argument as ByRef (ref in C#) or ByVal (default in C#)

Thursday, June 04, 2015

Time Span Check for Store Hours to show... Using a .NET Literal Control

I have done this countless times, but senior moments are happening.

Const timeHourOpen As Integer = 8
Const timeHourClosed As Integer = 16 'Set one hour less because at 5:00 the store will close

If (timeHourOpen <= DateTime.Now.Hour AndAlso DateTime.Now.Hour <= timeHourClosed) Then
   'Account for greater than 17 hundred hours aka 17:01
                            callCenterOpen.Visible = True
                            callCenterOpen.Visible = False
                        End If

That is all for today....

Now I will always refer back to the My Blog to review...

I like how the conditional logic is written

LowerBound <= Value <= Upper Bound

AndAlso for short circuiting

Till Next Post.