VBA/Excel/Access/Word/Data Type/Byte — различия между версиями

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

Текущая версия на 12:48, 26 мая 2010

Attempts to store the numbers 52 and 5.2 in a variable declared as type Byte.

 
Sub ByteDemo()
    Dim myVar As Byte
    myVar = 52
    Debug.Print myVar
    myVar = 5.2
    Debug.Print myVar
End Sub



You should also be careful about mixing numerical data types in mathematical operations

 
Sub Mix()
    Dim myAnswer As Byte
    Dim num1 As Single
    Dim num2 As Byte
    num1 = 4.1
    num2 = 5
    myAnswer = num1 * num2
End Sub