【问题标题】:Value of type 'Boolean' cannot be converted to 'Microsoft.Vbe.Interop.Forms.ReturnBoolean''Boolean' 类型的值不能转换为 'Microsoft.Vbe.Interop.Forms.ReturnBoolean'
【发布时间】:2012-03-27 18:51:27
【问题描述】:

首先,让我为您提供我的代码:

Private Sub txtLatMin_Exit(ByVal Cancel As ReturnBoolean)
    Dim i_SelStart As Long
    Dim str_Prompt As String


    'Save the cursor position.
    i_SelStart = txtLatMin.SelectionStart

    'Remove characters that we can't use.
    txtLatMin.Text = NumericPortion(txtLatMin.Text, True)

    'Enforce the maximums:
    If Val(txtLatMin.Text) + Val(txtLatSec.Text) / 60 >= 60 Then
        str_Prompt = "The maximum number of latitude minutes is 59.999."
        MsgBox(str_Prompt, vbExclamation, "Notification")
        Cancel = True
    ElseIf Val(Me.textbox_Latitude_Degrees.Text) + Val(txtLatMin.Text) / 60 + Val(txtLatSec.Text) / 3600 > 89.99 Then
        str_Prompt = "The maximum number of latitude degrees is 89.99."
        MsgBox(str_Prompt, vbExclamation, "Notification")
        Cancel = True
    End If

    'Restore the cursor position.
    txtLatMin.SelectionStart = i_SelStart
End Sub

它在 Cancel = True

标记此帖子标题中的错误

请记住,我正在将代码从 VB6 转换为 VB.NET

是否有人可以向我提供任何建议?

【问题讨论】:

  • 考虑丢弃并完全重写代码。迁移助手仅对不会更改的代码有用。一旦您需要进一步开发它,最好从头开始并正确执行,因为您迁移的代码总是会变得一团糟。您确实不想想要维护该代码。

标签: vb.net boolean type-conversion vb6-migration


【解决方案1】:

我相信你需要改变

Cancel = True

Cancel.Value = True

【讨论】:

  • 这是完美的。非常感谢。
猜你喜欢
  • 1970-01-01
  • 2015-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-24
相关资源
最近更新 更多