Using Variables : Variable « Language Basics « VBA / Excel / Access / Word






Using Variables

 

Sub AgeCalc()
      Dim FullName As String
      Dim DateOfBirth As Date
      Dim age As Integer

      FullName = "John Smith"
      DateOfBirth = #1/3/1967#
      age = Year(Now()) - Year(DateOfBirth)

      Debug.Print FullName & " is " & age & " years old."
End Sub

 








Related examples in the same category

1.declare several variables on the same line, separating each variable name with a comma
2.Assigning Values to Variables