使用messagebox.show时遇到问题

时间:2013-03-20 02:24:38

标签: vb.net winforms

我遇到了messagebox.show的问题。我想要答案,这句话“你想尝试另一种临时转换吗?”显示在带有yesno按钮的消息框中。

Public Class Form1
    Dim intFah As Windows.Forms.DialogResult

    Private Sub BtnFah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFah.Click
        Try
            Dim intFah As Integer

            intFah = CInt(TxtBoxTemp.Text)
            intFah = (intFah * 9) / 5 - 32
            MessageBox.Show(intFah.ToString & ControlChars.CrLf & "Would you like to start another temp conversion?", MessageBoxButtons.YesNo)
        Catch
            MessageBox.Show("Would you like to start another temp conversion?", "System Error", MessageBoxButtons.YesNo)

        End Try
    End Sub
End Class

1 个答案:

答案 0 :(得分:1)

你的代码不是为我构建的 - 这可能是因为你的MessageBox.Show:

MessageBox.Show(intFah.ToString & ControlChars.CrLf & "Would you like to start another temp conversion?", MessageBoxButtons.YesNo)

您没有传递正确数量的parameters。根据链接,它需要文本,标题(标题),然后按钮选项

如果我将其更改为:

MessageBox.Show(intFah.ToString & ControlChars.CrLf & "Would you like to start another temp conversion?", "A Caption", MessageBoxButtons.YesNo)

然后它构建,当我运行应用程序时,我可以根据您要查找的内容在一行中显示答案,在第二行显示文本。