gpt4 book ai didi

vb.net - 等价于 VB.Net 中的货币?

转载 作者:行者123 更新时间:2023-12-01 15:48:38 25 4
gpt4 key购买 nike

我正在将应用程序从 VB6 迁移到使用货币类/结构的 VB.Net。我的问题是:在以下代码中,哪个是 VB6 Currency 的“等价物”?

Public Function getTimeElapsed() As Double

Dim cuStart As Currency
Dim cuStop As Currency
Dim cuFreq As Currency
Dim v As Double
Dim ReturnValue As Double

QueryPerformanceFrequency(liFrequency)

cuStart = LargeIntToCurrency(liStart)
cuStop = LargeIntToCurrency(liStop)
cuFreq = LargeIntToCurrency(liFrequency)
' elapsed time
v = CDbl(cuStop - cuStart) / CDbl(cuFreq)
Select Case ResultUnit
Case CounterUnit.Second
ReturnValue = v
Case CounterUnit.Millisecond
ReturnValue = v * 1000.0#
Case CounterUnit.microsecond
ReturnValue = v * 1000000.0#
Case CounterUnit.nanosecond
ReturnValue = v * 1000000000.0#
End Select
Return ReturnValue
End Function
Private Function LargeIntToCurrency(liInput As LARGE_INTEGER) As Currency
CopyMemory(LargeIntToCurrency, liInput, Strings.Len(liInput))
LargeIntToCurrency = LargeIntToCurrency * 10000
End Function

'Currency' 在 VB.Net 中给出这样的错误。是否有任何缺少的库?

enter image description here

最佳答案

表示货币的数据应在 VB.NET 中存储为 Decimal 值。它不像 Double 那样容易出现舍入错误。

关于vb.net - 等价于 VB.Net 中的货币?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61654074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com