【问题标题】:Having trouble with the messagebox.showmessagebox.show 有问题
【发布时间】:2013-03-20 02:24:37
【问题描述】:

我在使用 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

【问题讨论】:

  • 使用返回值。

标签: vb.net winforms


【解决方案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)

然后它会构建,当我运行应用程序时,我可以得到答案出现在一行中,而文本则出现在第二行中。

【讨论】:

  • 谢谢!它现在正在工作。现在我只需要确保消息框上的按钮正常工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-09
  • 2011-11-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多