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

Материал из VB Эксперт
Версия от 12:46, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Tools for Debugging Code

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



Use Debug.Print to output the message to the immediate window

 
Sub addNumbers1()
   "Declare the variables
   Dim intNumber1 As Integer
   Dim intNumber2 As Integer
   Dim intSum As Integer
   "Create InputBoxes to enter numbers
   intNumber1 = 1
   intNumber2 = 2
   "Add numbers
   intSum = intNumber1 + intNumber
   Debug.Print "The numbers entered were " & intNumber1 & " and " & intNumber2
End Sub