[VBA ] 溢位問題

看板Visual_Basic作者 (豆子丁)時間5年前 (2018/06/22 16:26), 編輯推噓1(104)
留言5則, 2人參與, 5年前最新討論串1/2 (看更多)
當b值達到100左右時就會溢位,想請問如何解決 程式碼如下所示: Sub cal() Dim b As Long n = Range("H3") r = Range("H4") b = Range("H5") For i = 3 To n + 2 Cells(i, 4) = Cells(i, 2) ^ b ← 溢位 Cells(i, 5) = WorksheetFunction.Ln(Cells(i, 2)) Next i Cells(6, 8) = (WorksheetFunction.Sum(Range(Cells(3,4),Cells(n+2,4)))/r)^(1/ b) End Sub 謝謝 -- ◢◤▅▇▇▆▄ ▃▄▄▂ ▂▄▄▂◢◢▃▂▇▇▂▃▃▂ ▃▅▄▆◤ ▊ ▃▆ ▃▄▅▂ ▅▆▆▂ ▆▄▄▃▄▄▃ ▏ ▃▅▆ ▉▍ ▃▄▂ ▎ ▃▄ ▃▂ ▎ ▂▃ ▅▂▁ ▎▍▃▂▂▄ ▃ˍ▄ ▄▂ ▎ ▂▃ ▂▁ ▃▅▆ ◥◣▄▂ˍ▂▄ ▅▄▂▂▄ ▂▃▂▂ ▄▃▃▅ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.124.76.60 ※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1529655997.A.705.html

06/23 00:42, 5年前 , 1F
沒救吧噗 給你算到100次已經很爽了好嗎
06/23 00:42, 1F

06/26 12:14, 5年前 , 2F
Cells(i,4)=CLng(Cells(i,2).Value)^b
06/26 12:14, 2F

06/26 12:14, 5年前 , 3F
試試看,因為不清楚你數字到底放到多大
06/26 12:14, 3F

06/26 12:17, 5年前 , 4F
Cells(i,4)=CDec(Cells(i,2).Value)^CDec(b)
06/26 12:17, 4F

06/28 11:55, 5年前 , 5F
他需要cdbl吧噗 而且本來可能就是浮點在算 clng死更快
06/28 11:55, 5F
文章代碼(AID): #1RBBAzS5 (Visual_Basic)
討論串 (同標題文章)
文章代碼(AID): #1RBBAzS5 (Visual_Basic)