VBA/Excel/Access/Word/Language Basics/Debug.Assert

Материал из VB Эксперт
Перейти к: навигация, поиск

Assert

 
Sub addNumbers2()
   Dim intNumber1 As Integer
   Dim intNumber2 As Integer
   Dim intSum As Integer
   intNumber1 = 5
   intNumber2 = 3
   Debug.Assert intNumber1 = 5
   Debug.Assert intNumber2 = 7
   intSum = intNumber1 + intNumber2
   Debug.Print "The sum of the two numbers is: " & intSum
End Sub



Using Assertions

 
Sub Assertion()
    Dim intAge As Integer
    intAge = InputBox("Please Enter Your Age")
    Debug.Assert (intAge >= 0)
    msgBox "You are " & intAge
End Sub