在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'.
答案 0 :(得分:3)
IsLast = If( CursorPos = Len(numText.Text), 1, 0 )
您是否尝试将较大的VB6块迁移到VB.Net?
答案 1 :(得分:1)
IsLast = CursorPos = Len(numText.Text)