在 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'.