1

## VB 數值看起來一樣，VB卻說不同

``````        邊長(1) = 15
邊長(2) = 21.213
邊長(3) = 15
MsgBox(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3) &
vbNewLine & 邊長(2) & vbNewLine & "是否相等:" &
IIf(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3) = 邊長(2), "true", "fels"))
``````

Zed_Yang iT邦新手 3 級 ‧ 2019-10-07 17:49:24 檢舉

IIf(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3) = 邊長(2), "true", "fels"))

Zed_Yang iT邦新手 3 級 ‧ 2019-10-07 17:54:14 檢舉

MsgBox(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3) &
vbNewLine & 邊長(2) & vbNewLine & "是否相等:" &
IIf(CDec(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3)) = CDec(邊長(2)), "true", "false"))
Zed_Yang iT邦新手 3 級 ‧ 2019-10-07 18:15:16 檢舉

Dim a = 15
Dim b = 21.213
Dim c = 15
MsgBox(Math.Round((c ^ 2 + a ^ 2) ^ 0.5, 3) & vbNewLine & b & vbNewLine & "是否相等:" & IIf(Math.Round((c ^ 2 + a ^ 2) ^ 0.5, 3) = b, "true", "false"))

re:Anthony_Yang

Zed_Yang iT邦新手 3 級 ‧ 2019-10-08 10:56:05 檢舉

Array A[0] = 3, Array B[0] = 3
A[0] == B[0] 是false

### 3 個回答

0

iT邦高手 1 級 ‧ 2019-10-07 23:06:11

``````        Dim 邊長(3) As Single
邊長(1) = 15
邊長(2) = 21.213
邊長(3) = 15
MsgBox(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3) &
vbNewLine & 邊長(2) & vbNewLine & "是否相等:" &
IIf(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3) = Math.Round(邊長(2), 3), "true", "fels"))

邊長(3) = 21.213
MsgBox(Math.Round(邊長(3), 3) & vbNewLine & 邊長(2) & vbNewLine & "是否相等:" &
IIf(Math.Round(邊長(3), 3) = 邊長(2), "true", "fels"))
``````

0
Zed_Yang
iT邦新手 3 級 ‧ 2019-10-08 10:57:24

``````邊長(1) = 15

MsgBox(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3) &
vbNewLine & 邊長(2) & vbNewLine & "是否相等:" &
IIf(CDec(Math.Round((邊長(3) ^ 2 + 邊長(1) ^ 2) ^ 0.5, 3)) = CDec(邊長(2)), "true", "false"))
``````

``````Dim a = 15
Dim b = 21.213
Dim c = 15
MsgBox(Math.Round((c ^ 2 + a ^ 2) ^ 0.5, 3) & vbNewLine & b & vbNewLine & "是否相等:" & IIf(Math.Round((c ^ 2 + a ^ 2) ^ 0.5, 3) = b, "true", "false"))

``````
0
owlfox
iT邦新手 5 級 ‧ 2019-10-08 16:22:31

Debug.Print ((0.1 + 0.2) - 0.3);