Showing posts with label Data Types. Show all posts
Showing posts with label Data Types. Show all posts

Saturday, February 25, 2023

Data type - Type conversion functions

Type conversion functions

Each function coerces or forces an expression to a specific data type. The expression will be converted to a specific data type. For example, CBool(expression). This function converted expression to a Boolean data type which is TRUE or FALSE with condition expression is a numeric or valid string, otherwise Rune-time error '13': Type mismatch. The function name determines the return type as shown in the following:

Function Returns the expression converted to a
CBool Boolean data type (Boolean).
CByte Byte data type (Byte).
CCur Currency data type (Currency).
CDate Date data type (Date).
CDbl Double data type (Double).
CDec Decimal data type (Decimal).
CInt Integer data type (Integer).
CLng Long data type (Long).
CLngLng LongLong data type (LongLong).
CLngPtr LongPtr data type (LongPtr).
CSng Single data type (Single).
CStr String data type (String).
CVar Variant data type (Variant).

VBA Vode:

Option Explicit
Sub ExampleTypeOfConverstion()

    Debug.Print CBool(1) 'Return True
    Debug.Print CBool(0) 'Return False
    Debug.Print CBool(-1) 'Return True
    Debug.Print CBool(100) 'Return True
'    Debug.Print CBool("TEST") 'Rune-time error '13': Type mismatch

End Sub
Read more about Type conversion functions, excel training beginners, coding in vba,
excel training online, visual basic for applications at below links.

Microsoft Reference-Type-conversion-functions
Other Reference-Data-types-category

Leave your comments if you have any request.
Practice makes perfect.
Thank You.

Monday, January 16, 2023

Data type - User defined

User defined data type can be any data type using a Type statement which is more related to groups of variables. Declaration must be done at module level above the sub procedure, otherwise compile error: Invalid inside procedure as below.

Syntax : 

Type MyType
    Field1 as Any Data type
    Field2 as Any Data type
    .
    .
End Type

The above syntax must be declare at module level and below statement is inside sub procedure.

Dim MyVar as MyType

From here we can access Field1,Field2,... and etc.

Refer below for example:

VBA Vode:

Option Explicit
Type MyDetails
    Myname As String
    MyAge As Integer
    MyBirthDate As Date
    MyMarried As Boolean
End Type
Sub DataTypeExample_UserDefined()

    Dim MyBio As MyDetails
    
    MyBio.Myname = "Nazri"
    MyBio.MyAge = 50
    MyBio.MyBirthDate = "05/06/1978"
    MyBio.MyMarried = True
    
    MsgBox ("My name is " & MyBio.Myname & " my age is " & _
            MyBio.MyAge & " and married is " & MyBio.MyMarried)
    
End Sub

Note:
This User defined data type is more to static, we can't changed this inside our code only at design stage.

Read more about User defined data type, macro enabled excel, excel macro,
vba coding, vba code at below links.

Microsoft Reference-User-defined-data-type
Other Reference-User-defined-types.htm

Leave your comments if you have any request.
Practice makes perfect.
Thank You.

Saturday, January 7, 2023

Data type - Object

Object data type is refer to any objects in excel and store as 32-bit (4-byte) and Set statement must be use after declares otherwise Run-time error '91': Object variable or with block variable not set in syntax.

Syntax : Dim MyVar as Object
               Set MyVar = Object

Object can be any objects assigned to it for example: Workbook, Worksheet, Chart and etc
(Refer below link for Object model).

Below Example is to check whether active sheet is empty or not?

VBA Vode:

Option Explicit
Sub ToCheckActiveSheetEmpty()
    
    Dim MyWS As Worksheet
    Dim MyRng As Range
    Set MyWS = ActiveSheet
    Set MyRng = MyWS.UsedRange
    
    If WorksheetFunction.CountA(MyRng) = 0 And _
    MyWS.Shapes.Count = 0 Then
        MsgBox "Sheet " & """" & MyWS.Name & """" & " is empty", _
        vbInformation, "https://mrvba.blogspot.com"
    Else
        MsgBox "Sheet " & """" & MyWS.Name & """" & "  is not empty", _
        vbInformation, "https://mrvba.blogspot.com"
    End If

End Sub

Note: There are 2 objects inside the example. 1st Worksheet and 2nd is Range.

Read more about Object data type, excel training beginners, coding in vba,
excel training online, visual basic for applications at below links.

Microsoft Reference-Object-data-type
Microsoft Reference-Object-model

Leave your comments if you have any request.
Practice makes perfect.
Thank You.

Wednesday, December 21, 2022

Data type - LongPtr

LongPtr data type is a variable declared type depend on platform or system used.
For 32-bit systems and the numbers ranging in value from -2,147,483,648 to 2,147,483,647
translate as Long.
For 64-bit systems and the numbers ranging in value from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807  translate as LongLong.

Declaration : Dim Var as LongPtr

Where Var refer as variable.

Note:
This data type is very seldom used and this data type should be used for pointers and handles..

Read more about Longptr data type, macro enabled excel, excel macro,
vba coding, vba code at below links.

Microsoft Reference-Longptr-data-type
Other Reference-Longptr-data-type

Leave your comments if you have any request.
Practice makes perfect.
Thank You.

Data type - LongLong

Longlong data type is a variable declared type only valid on 64-bit platforms and the numbers ranging in value from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

Declaration : Dim Var as LongLong or
                       Dim Var^

Where Var refer as variable instead of LongLong we can use caret (^) to represent this data type.

Note:
This data type is very seldom used unless we know each user what platform they use, either 32bit or 64bit system. Long data type is more flexible.

Read more about Longlong data type, excelmacros, macro excel,
excel programming, excel vba at below links.

Microsoft Reference-Longlong-data-type
Other Reference-Longlong-data-type

Leave your comments if you have any requests.
Practice makes perfect.
Thank you.

Tuesday, November 1, 2022

Data type - Variant

Data type Variant is represent all data type for variables even more widen or general. If we declare variables without data type at the end then system consider as variant. We can choose either Dim VrtVar as Variant or Dim VrtVar only. In case we don't know what data type to use then Variant is the only choice we have.

For more example refer below table and code.
Below example we try to group the data either number, string, date or empty.

VBA Vode:

Option Explicit
Sub Examples_DataType_Variant()
    
    Dim i As Integer, StrVar
    With ActiveSheet
        i = 2
        Do
            StrVar = .Range("B" & i)
            If IsEmpty(StrVar) Then
                Range("C" & i) = "Empty"
            ElseIf IsDate(StrVar) Then
                Range("C" & i) = "Date"
            Else
                If IsNumeric(StrVar) Then
                    Range("C" & i) = "Number"
                Else
                    Range("C" & i) = "String"
                End If
            End If
            Set StrVar = Nothing
            i = i + 1
        Loop While .Range("A" & i) <> ""
    End With
    
End Sub

Note:
Please remember Variant data type is not easy to handle because we need to test before proceed otherwise it will generate error.

Microsoft Reference-Variant-data-type
Other Reference-Variant-data-type

Practice makes perfect. Thank You.

excelmacros
macro excel
excel programming
excel vba

Saturday, October 22, 2022

Data type - String

Data type String is any characters in sequence, 2 type of string:

  • Variable-length contain up to approximately 2 billion (2^31) characters.
    Declare Dim StrText as String or Dim StrText$
  • Fixed-length strings contain 1 to approximately 64 K (2^16) characters.
    Declare Dim StrText as String * 3, where 3 is length of string

To reset or assign String as empty StrText = "" (Use double-quotation-marks) and to include double-quotation-marks inside string StrText = """" (Indicate single double-quotation-marks inside string).

For more example refer below table and code.

Below example is to get folder name and files name from path.

VBA Vode:

Option Explicit
Sub Examples_StringVariablelength()

    Dim i As Integer
    Dim StrPath As String, StrFldr As String
    
    i = 2
    With ActiveSheet
        Do
            
            StrPath = .Range("B" & i)
            StrFldr = Left(StrPath, InStrRev(StrPath, "\", -1) - 1)
            .Range("C" & i) = Right(StrFldr, Len(StrFldr) - _
            InStrRev(StrFldr, "\", -1))
            .Range("D" & i) = Right(StrPath, Len(StrPath) - _
            InStrRev(StrPath, "\", -1))
            
            StrPath = "": StrFldr = ""
            i = i + 1
        Loop Until .Range("A" & i) = ""
    End With

End Sub

Note: 

Above example include Left function, Right function and InStrRev function.

Below example is to get months name in short form (3 Characters) with fixed length variables and left function.

VBA Vode:

Option Explicit
Sub Examples_StringFixedLength()

    Dim i As Integer
    Dim StrMnth As String * 3
    i = 2
    With ActiveSheet
        Do
            
            StrMnth = .Range("B" & i)
            .Range("C" & i) = Left(.Range("B" & i), 3)
            .Range("D" & i) = StrMnth
            
            StrMnth = ""
            i = i + 1
        Loop Until .Range("A" & i) = ""
    End With

End Sub

Note: 

The variables length string is widely used compare with fixed length string.

Microsoft Reference-String-data-type
Other Reference-String-data-type

Practice makes perfect. Thank You.

excelmacros
macro excel
excel programming
excel vba

Thursday, October 20, 2022

Data type - Single

Data type Single is short for single precision floating point are stored as IEEE 32-bit (4-byte) ranging for negative values -3.402823E38 to -1.401298E-45 and for positive values 1.401298E-45 to 3.402823E38. Different from Double, Single can support 7 significant figures with 6 decimal places only. Single, Double and Decimal most probably at the same group may be different by range and accuracy of decimal points. Instead of Dim SglNum as Single we can use Dim SglNum!.

For more example refer below table and code. 

Below we try to get area in square meter base on width and length.

Base on result there is huge different in figure especially on decimal points. Which one is more accurate in this case? Double is the same as Direct.

VBA Vode:

Option Explicit
Sub Examples_Single()
    
    Dim i As Long
    
    'Single Declaration
    Dim SglOpnStk As Single, SglInOut As Single
    Dim SglClsStk!
    
    'Double Declaration
    Dim DblOpnStk As Double, DblInOut As Double
    Dim DblClsStk#
    
    i = 2
    With ActiveSheet
        Do
            'Sgleger
            SglOpnStk = .Range("B" & i): SglInOut = .Range("C" & i)
            SglClsStk = SglOpnStk * SglInOut
            
            'Long
            DblOpnStk = .Range("B" & i): DblInOut = .Range("C" & i)
            DblClsStk = DblOpnStk * DblInOut
            
            'Direct input
            .Range("D" & i) = .Range("B" & i) * .Range("C" & i)
            .Range("E" & i) = SglClsStk 'Single variables
            .Range("F" & i) = DblClsStk 'Double variables
            
            SglOpnStk = 0: SglInOut = 0: SglClsStk = 0
            DblOpnStk = 0: DblInOut = 0: DblClsStk = 0
            
            i = i + 1
        Loop Until .Range("A" & i) = ""
    End With

End Sub

Note: 

Single.Double and Decimal at the same group and choose wisely. Same as Integer and Long.

Microsoft Reference-Single-data-type
Other Reference-Single-data-type

Practice makes perfect. Thank You.

excelmacros
macro excel
excel programming
excel vba

Data type - Long

Data type Long is short for long integers are stored as signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647. Declare as Dim LngNum as Long or Dim LngNum&. Compare with integer, long is more bigger range and required more space in your computer memory.

For more example refer below table and code. 

Below table we try to get balance stock after top up and deduction by using different data type for example direct input, long and integer.

Base on result there is huge different in figure, long is still accurate but integer is totally wrong because the data is out of range for integer itself.

VBA Vode:

Option Explicit
Sub Examples_Integer()
    
    Dim i As Long
    
    'Integer Declaration
    Dim IntOpnStk As Integer, IntInOut As Integer
    Dim IntClsStk%
    
    'Decimal Declaration
    Dim LngOpnStk As Long, LngInOut As Long
    Dim LngClsStk&
    
    i = 2
    With ActiveSheet
        Do
            'Integer
            On Error Resume Next
            IntOpnStk = .Range("C" & i): IntInOut = .Range("D" & i)
            IntClsStk% = IntOpnStk + IntInOut
            
            'Long
            LngOpnStk = .Range("C" & i): LngInOut = .Range("D" & i)
            LngClsStk& = LngOpnStk + LngInOut
            
            'Direct input
            .Range("E" & i) = .Range("C" & i) + .Range("D" & i)
            .Range("F" & i) = LngClsStk& 'Long variables
            .Range("G" & i) = IntClsStk% 'Integer variables
            
            IntOpnStk = 0: IntInOut = 0: IntClsStk% = 0
            LngOpnStk = 0: LngInOut = 0: LngClsStk& = 0
            
            i = i + 1
        Loop Until .Range("A" & i) = ""
    End With

End Sub

Note: 

Please careful choose your data type unless your output is totally wrong after process, if you're lucky then error message will prompt for verification.

Microsoft Reference-Long-data-type
Other Reference-Long-data-type

Practice makes perfect. Thank You.

macro enabled excel
excel macro
vba coding
vba code

Wednesday, October 19, 2022

Data type - Integer

Data type integer stored as 16-bit (2-byte) numbers ranging in value from -32,768 to 32,767. One byte is used to represent the sign either positive (+ve) or negative (-ve). Can be declare Dim IntNum as integer or Dim IntNum%. If assigned data is out of range then error "Run time error '6': Over flow.

For more example refer below table and code. 

Below table we try to get balance stock after top up and deduction by using different data type for example direct input, integer and long.


 Base on result there is no different in figure, but long is better unless we are sure the quantity is not out of range.

VBA Vode:

Option Explicit
Sub Examples_Integer()
    
    Dim i As Long
    
    'Integer Declaration
    Dim IntOpnStk As Integer, IntInOut As Integer
    Dim IntClsStk%
    
    'Decimal Declaration
    Dim LngOpnStk As Long, LngInOut As Long
    Dim LngClsStk&
    
    i = 2
    With ActiveSheet
        Do
            'Integer
            IntOpnStk = .Range("C" & i): IntInOut = .Range("D" & i)
            IntClsStk% = IntOpnStk + IntInOut
            
            'Long
            LngOpnStk = .Range("C" & i): LngInOut = .Range("D" & i)
            LngClsStk& = LngOpnStk + LngInOut
            
            'Direct input
            .Range("E" & i) = .Range("C" & i) + .Range("D" & i)
            .Range("F" & i) = IntClsStk% 'Integer variables
            .Range("G" & i) = LngClsStk& 'Long variables
            
            IntOpnStk = 0: IntInOut = 0: IntClsStk% = 0
            LngOpnStk = 0: LngInOut = 0: LngClsStk& = 0
            
            i = i + 1
        Loop Until .Range("A" & i) = ""
    End With

End Sub

Note:

Number of Maximum rows in Excel is 1,048,576 and Maximum columns is 16,384. Therefore loop through used range in rows must used long and columns as integer enough.

Microsoft Reference-Integer-data-type
Other Reference-Integer-data-type

Practice makes perfect. Thank You.

excelmacros
macro excel
excel programming
excel vba

Tuesday, October 18, 2022

Data type - Double

Data type Double is refer to short for double precision floating point are stored as IEEE 64-bit (8-byte) ranging from:

  • -1.79769313486231E308 to -4.94065645841247E-324 for negative values
  • 4.94065645841247E-324 to 1.79769313486232E308 for positive values

Instead of Dim DbNum as Double we can use Dim DbNum#. The key point here is precision floating point (read more at link below) this can support 15 significant figures with 14 decimal places.

For more example refer below table and code.

Below we try to get area in square meter base on width and length.


VBA Vode:

Option Explicit
Sub Examples_DoubleVariales()
    
    Dim i As Integer
    
    'Double Declaration
    Dim DbWidht As Double, DbLength As Double
    Dim DbSqMtr As Double
    
    'Decimal Declaration
    Dim VarWidht As Variant, VarLength As Variant
    Dim VarSqMtr As Variant
    
    'Integer Declaration
    Dim IntWidht As Integer, IntLength As Integer
    Dim IntSqMtr As Integer
    
    i = 2
    With ActiveSheet
        Do
            'Double
            DbWidht = .Range("B" & i)
            DbLength = .Range("C" & i)
            DbSqMtr = Round(DbWidht * DbLength, 2)
            
            'Decimal
            VarWidht = CDec(.Range("B" & i))
            VarLength = CDec(.Range("C" & i))
            VarSqMtr = CDec(Round(VarWidht * VarLength, 2))
            
            'Integer
            IntWidht = .Range("B" & i)
            IntLength = .Range("C" & i)
            IntSqMtr = Round(IntWidht * IntLength, 2)
            
            'Direct input
            .Range("D" & i) = Round(.Range("B" & i) * _
            .Range("C" & i), 2)
            .Range("E" & i) = DbSqMtr 'Double variables
            .Range("F" & i) = VarSqMtr 'Decimal variables
            .Range("G" & i) = IntSqMtr 'Integer variables
            
            DbWidht = 0: DbLength = 0: DbSqMtr = 0
            VarWidht = 0: VarLength = 0: VarSqMtr = 0
            IntWidht = 0: IntLength = 0: IntSqMtr = 0
            i = i + 1
        Loop Until .Range("A" & i) = ""
    End With

End Sub

Note: The above example we try to compare without variables, Double variables, Decimal variables and Integer variables. Definitely integer is not accurate for this type of data.

Microsoft Reference-Double-data-type
Other Reference-Double-data-type
Other Reference-Floating-point-numbers

Practice makes perfect. Thank You.

macro enabled excel
excel macro
vba coding
vba code

Monday, October 17, 2022

Data type -Decimal

Data type Decimal is stored as 96-bit (12-byte) and range for data without decimal value (0) between +/-79,228,162,514,264,337,593,543,950,335 and with 28 decimal point between +/-7.9228162514264337593543950335 and the smallest, non-zero value is +/-0.0000000000000000000000000001. Beside Decimal we can use Double which is more straight forward but in term accuracy better use Decimal depend on condition.

VBA Vode:

Option Explicit
Sub Examples_Decimal()
    
    'Integer Variable Declaration
    Dim DecVar As Variant
    
    'Assign value to integer variable
    DecVar = CDec(50555555000.1004)

    'Checking what type of data
    Debug.Print TypeName(DecVar) 'Decimal

End Sub

Result: Data type shown as Decimal

VBA Vode:

Option Explicit
Sub Examples_DecimalVsDouble()

    'Variables with Decimal declaration
    Dim DecVarA As Variant, DecVarB As Variant
    
    'Variables with Double declaration
    Dim DblVarA As Double, DblVarB As Double
    
    DecVarA = CDec(0.2): DecVarB = CDec(0.21) 'Decimal
    DblVarA = 0.2: DblVarB = 0.21 'Double
    
    Debug.Print DecVarA + DecVarB = 0.41    'True
    Debug.Print DblVarA + DblVarB = 0.41    'False
    
End Sub

Note: For comparison the result for Variant/Decimal is True but the result for Double is False. Meaning Variant/Decimal is more accurate compare with Double.

Microsoft Reference-Decimal-data-type
Other Reference-Decimal-data-type.htm

Practice makes perfect. Thank You.

excelmacros
macro excel
excel programming
excel vba

Sunday, October 16, 2022

Data type - Date and Time

Data type Date are stored as IEEE 64-bit (8-byte) ranging from 1 January 100, to 31 December 9999, and times from 0:00:00 to 23:59:59. The Date uses decimal numbers to represent the date and time together therefore our result must be declare as Double.

VBA Vode: (To get different date in Hours, Days, Months and Years)

Option Explicit
Sub Examples_DateDiffer()
    
    Dim DtNumA As Date, DtNumB As Date
    Dim DtNumHr As Long, DtNumDy As Long
    Dim DtNumMn As Long, DtNumYr As Integer
    
    DtNumA = "16-10-2022": DtNumB = "16-10-2021"
    If DtNumA - DtNumB > 0 Or DtNumA - DtNumB < 0 Then
        DtNumHr = DateDiff("H", DtNumB, DtNumA) 'Different in Hours
        DtNumDy = DateDiff("D", DtNumB, DtNumA) 'Different in Days
        DtNumMn = DateDiff("M", DtNumB, DtNumA) 'Different in Months
        DtNumYr = DateDiff("YYYY", DtNumB, DtNumA) 'Different in Years
    Else
        MsgBox "Sorry! Same date compare.TQ"
        Exit Sub
    End If
     
    Debug.Print "Hours: " & DtNumHr, "Days: " & DtNumDy, _
    "Months: " & DtNumMn, "Years: " & DtNumYr

End Sub

Answer: Hours: 8760   Days: 365     Months: 12    Years: 1

VBA Vode: (To get date after add Days, Months and Years)

Option Explicit
Sub Examples_DateAdded()
    
    Dim DtBefore As Date, DtAfterDy As Date
    Dim DtAfterMn As Date, DtAfterYr As Date
    
    DtBefore = DateValue("Oct 16, 2022")
    DtAfterDy = DateAdd("d", 3, DtBefore) 'Add 3 days after
    DtAfterMn = DateAdd("m", 3, DtBefore) 'Add 3 months after
    DtAfterYr = DateAdd("yyyy", 3, DtBefore) 'Add 3 years after
    
    Debug.Print "Add 3 Days: " & DtAfterDy, "Add 3 Months: " & _
    DtAfterMn, "Add 3 Years: " & DtAfterYr
    
End Sub

Answer: Add 3 Days: 19/10/2022      Add 3 Months: 16/1/2023     Add 3 Years: 16/10/2025

VBA Vode: (To get current date and time)

Option Explicit
Sub Examples_DateCurrent()

    Dim DtNowDef As Date, DtNowCst As String
    
    DtNowDef = Now() 'Default
    DtNowCst = VBA.Format(Now(), "mm.dd.yy hh:mm") 'Custom
    
    Debug.Print "Default: " & DtNowDef, "Custom: " & DtNowCst

End Sub

Answer: Default: 16/10/2022 9:55:07 PM            Custom: 10.16.22 21:55
(The answer base on my own time when run this code)

Note: 

To converts a string to time serial number we use TimeValue function. The time's serial number is a number between 0 and 1. For example, Afternoon (half day) is represented by 0.5.

Microsoft Reference-Date-data-type
Other Reference-Date-data-type

Practice makes perfect. Thank You.

macro enabled excel
excel macro
vba coding
vba code

Data type - Currency

Data type Currency stored as 64-bit (8-byte) numbers in an integer format, maximum 15 digit number with 4 digit decimal point. Range between -922,337,203,685,477.5808 to 922,337,203,685,477.5807. The error code same as byte if we assigned out range "Run-time error '6' Overflow.

VBA Vode:

Option Explicit
Sub Examples_Currency()
    
    Dim DbNumA As Double, DbNumB As Double
    Dim CurNum As Currency
    
    DbNumA = 10.5678942563: DbNumB = 15.010234201356
    If Not Abs(DbNumA - DbNumB) > 999999999999999# Then
        CurNum = DbNumA - DbNumB
    Else
        MsgBox "Sorry! Data overflow.TQ"
    End If
    
    Debug.Print CurNum

End Sub

Note: 

The answer above example is -4.4423, only 4 decimal points is allow for data type currency even original data is more than that.

Microsoft Reference-Currency-data-type
Other Reference-Currency-data-type.htm

Practice makes perfect. Thank You.

macro enabled excel
excel macro
vba coding
vba code

Data type - Byte

Data type Byte store as single 8-bit (1-byte) numbers from 0-255. The default value is 0 and no negative value and more than 255. It will generate error when we try to assigned out of range "Run-Time Error '6' over flow.

VBA Vode:

Option Explicit
Sub Examples_Byte()
    
    Dim iNumA As Integer, iNumB As Integer
    Dim BytNum As Byte
    
    iNumA = 10: iNumB = 15
    If Not Abs(iNumA - iNumB) > 255 Then
        BytNum = Abs(iNumA - iNumB) 'Remove negative sign
    Else
        MsgBox "Sorry! Data overflow.TQ"
    End If
    
    Debug.Print BytNum

End Sub

Note: 

Above example we use ABS function to remove negative sign and get absolute value and test the value over 255 or not then only assigned Byte data type.

Microsoft Reference-Byte-data-type
Other Reference-Byte-data-type.htm

Practice makes perfect. Thank You.

excelmacros
macro excel
excel programming
excel vba

Saturday, October 15, 2022

Data type - Boolean

Data type Boolean is only True ( -1 ) Or False ( 0 ) and basically stored as 16-bit (2-byte) numbers. The default is False or 0 (zero) but if the statement result other than 0 then it consider True. For example we have numbers A=5 and B=5 then A-B=0 then boolean consider False and vice versa.

VBA Vode:

Option Explicit
Sub Examples_Boolean()

    Dim iNumA As Integer, iNumB As Integer
    Dim BlResult As Boolean
    
    iNumA = 10: iNumB = 5
    BlResult = Not (iNumA < iNumB)
    
    Debug.Print BlResult

End Sub

Note: 

The result for the above code is True? Don't get confuse when we use Not operator, because inside bracket statement is False (10<5) then operator Not reverse the statement become True.

Microsoft Reference-Boolean-data-type
Other Reference-Boolean-data-type

Practice makes perfect. Thank You.

macro enabled excel
excel macro
vba coding
vba code