0

在 VB6 我有这样的代码:

IsLast = Abs(CursorPos = Len(numText.Text))

什么将 false 评估为 0,将 true 评估为 1。

这行代码在 VB.NET 中产生错误。

如何正确写这个?

编辑:错误是:

Error   15  Overload resolution failed because no accessible 'Abs' can be called without a narrowing conversion:
'Public Shared Function Abs(value As Decimal) As Decimal': Argument matching parameter 'value' narrows from 'Boolean' to 'Decimal'.
'Public Shared Function Abs(value As Double) As Double': Argument matching parameter 'value' narrows from 'Boolean' to 'Double'.
'Public Shared Function Abs(value As Single) As Single': Argument matching parameter 'value' narrows from 'Boolean' to 'Single'.
'Public Shared Function Abs(value As Long) As Long': Argument matching parameter 'value' narrows from 'Boolean' to 'Long'.
'Public Shared Function Abs(value As Integer) As Integer': Argument matching parameter 'value' narrows from 'Boolean' to 'Integer'.
'Public Shared Function Abs(value As Short) As Short': Argument matching parameter 'value' narrows from 'Boolean' to 'Short'.
'Public Shared Function Abs(value As SByte) As SByte': Argument matching parameter 'value' narrows from 'Boolean' to 'SByte'.
4

2 回答 2

3
IsLast = If( CursorPos = Len(numText.Text), 1, 0 )

您是否正在尝试将更大的 VB6 迁移到 VB.Net?

于 2012-10-28T19:38:51.043 回答
1
IsLast = CursorPos = Len(numText.Text)
于 2012-10-28T19:39:37.537 回答