Colleagues,
There's a very helpful built-in function in the VFP: BETWEEN(tArg, tMin, tMax), that evaluates whether the Arg is within the Max and Min limits, and returns Boolean flag.
What I liked the most about this function was that it took parameters of different data types (as long as all three were of the same one).
Now I need to mimic this function in VB .NET (the reasons are multiple, long story). Naturlich, I intend to overload it for Integer, Float, Char and String types (yes, VFP's BETWEEN() can work with that latter type as well!)
I tried to use TypeOf operator, and... see for yourself:
And the VS marks this tiArg as erring:
Article in ain't no help for yours truly: I can't see how sample there differs from my code syntax-wise...
Could you, please, explain to me what am I doing wrong?
TIA!
Regards,
Ilya
There's a very helpful built-in function in the VFP: BETWEEN(tArg, tMin, tMax), that evaluates whether the Arg is within the Max and Min limits, and returns Boolean flag.
What I liked the most about this function was that it took parameters of different data types (as long as all three were of the same one).
Now I need to mimic this function in VB .NET (the reasons are multiple, long story). Naturlich, I intend to overload it for Integer, Float, Char and String types (yes, VFP's BETWEEN() can work with that latter type as well!)
I tried to use TypeOf operator, and... see for yourself:
Code:
'====================================================================================================================================
Public Function Between(ByVal tiArg As Integer, ByVal tiMin As Integer, ByVal tiMax As Integer) As Boolean
'====================================================================================================================================
' Purpose : Checks if given Argument's value is between Min and Max values.
' Description :
' Parameters :
' Returns : Yes/No flag as Boolean.
' Side effects : None.
' Notes : 1. Generic.
' 2. Complies with .NET Framework ver. X.X and higher.
' 3. If any of the arguments is not of type Int - notifies the User and returns False
' Author : Ilya I. Rabyy
' Revisions : by Ilya on 2022-08-26 - started 1st draft.
'====================================================================================================================================
Dim llRet As Boolean = True
llRet = TypeOf tiArg Is Integer
If Not llRet Then Return llRet
Return llRet
End Function
'====================================================================================================================================
And the VS marks this tiArg as erring:
Article in ain't no help for yours truly: I can't see how sample there differs from my code syntax-wise...
Could you, please, explain to me what am I doing wrong?
TIA!
Regards,
Ilya