BMI VBA溢位訊息

--

今日練習BMI caculator , 一直出現overflow的錯誤訊息.

看起來有問題的程式碼是:bmi = weight /(height/100)²

第四行&第五行應該是要改成:

Height= Range(“B4”) Weight=Rang3(“B5”)

改寫成如下,就不再出現溢位訊息~

Sub ElseIfBMI()
Dim height As Integer: height = Range(“B4”)
Dim weight As Double: weight = Range(“B5”)
Dim bmi As Double
Dim result As String
bmi = weight / (height * height / 10000)

--

--

K.C.H潔克琳
K.C.H潔克琳

Written by K.C.H潔克琳

Lifelong learner, empath, looking for cozy worlds

No responses yet