La fonction TypeName dans VBA est utilisée dans les macros pour renvoyer le type de variable.
La fonction TypeName
La fonction VBA TypeName suit la syntaxe suivante :
Typename(variable)
Exemple de macro avec TypeName
La macro
Sub nommacro()
Dim a, b As String, c As Integer, d As Currency
Dim e(1 To 5) As Integera = Null
Cells(1, 1) = TypeName(a)
Cells(2, 1) = TypeName(b)
Cells(3, 1) = TypeName(c)
Cells(4, 1) = TypeName(d)
Cells(5, 1) = TypeName(e)End Sub
Le résultat
A | B | C | D | E | |
---|---|---|---|---|---|
1 | Null | ||||
2 | String | ||||
3 | Empty | ||||
4 | Currency | ||||
5 | Integer() |