VBA/Excel/Access/Word/Data Type/Byte

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

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