我在UWP很新,所以对我来说很难。我正在创建一些基本的caluclator,开始看看我可以吃这个东西。我遇到了一些小问题,即弹出窗口的错误处理。
On Error Resume Next
Dim check2 As Double
check2 = YA_txt.Text * 1
If Error.Number = 0 Then GoTo XA
If Error.Number > 0 Then GoTo error2
error2:
If Error.Number = 13 Then
MsgBox("Wrong coordinates", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error")
End If
但是现在我没有MsgBox并且有MessageDialog但它是异步的,这不能用于Error和Resume ...我该如何处理它?
感谢您的帮助:)
答案 0 :(得分:0)
您可以使用try catch而不是出错,并且您将根据错误类型显示消息。
Try
Dim check2 As Double
check2 = TextBox1.Text * 1
Catch ex As ArithmeticException 'type exception
Dim dialog = New MessageDialog("Wrong coordinates")
dialog.Title = "Error"
dialog.Commands.Add(New UICommand() With { Key.Label = "Ok", Key.Id = 0})
dialog.Commands.Add(New UICommand() With { Key.Label = "Cancel", Key.Id = 1})
Dim res = Await dialog.ShowAsync()
Catch ex As ArgumentException
'...
'Catch ....
End Try