首先,让我向您提供我的代码:
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
在取消=真实
标记此帖子标题中的错误请记住,我正在将代码从VB6转换为VB.NET
有人可以提供给我的任何建议吗?
答案 0 :(得分:2)
我相信你需要改变
Cancel = True
到
Cancel.Value = True