Vb.net 无法将“Cursor”类型的值转换为“Short”

Vb.net 无法将“Cursor”类型的值转换为“Short”,vb.net,Vb.net,我已将VB6迁移到dot net,并获得: 无法将“Cursor”类型的值转换为“Short” 这是我的密码: Dim intSavePointer As Short ' Save off the MousePointer ' Change the mouse pointer to clue in user of update intSavePointer = **MyBase.Cursor**(this is the error line of code) ' Change the mo

我已将VB6迁移到dot net,并获得:

无法将“Cursor”类型的值转换为“Short”

这是我的密码:

Dim intSavePointer As Short ' Save off the MousePointer

' Change the mouse pointer to clue in user of update

intSavePointer = **MyBase.Cursor**(this is the error line of code)

' Change the mouse pointer back

 **MyBase.Cursor** = intSavePointer
如何解决此问题?

将Dim intSavePointer短变为Dim savedCursor光标


游标不是int。我不知道为什么它在VB6中工作过,但我从未使用过。

在.NET中,我建议用Try/Finally将其包装起来,以确保即使您从例程中意外退出(例如异常),游标也会返回。@nanehero或使用Dim savedCursor=MyBase.Cursor并启用选项推断,然后,您不需要确切地知道类型是什么,VB将从表达式中推断出来。