message property

  • Thread starter Thread starter marcmc
  • Start date Start date
M

marcmc

I want to get the string from my outputted message and
put it in a text box. Can I? Anybody know how?

If MessageBox.Show("Error: A database connection error
has occurred. Do you want to see further details ?") Then

dim myMessage as string
TextBox1.Text = myMessage
 
Don't quite understand where your message is output from, if you mean the
same text as the messagebox then why not do something like:-

Dim myMessage As String
myMessage = "Error: A database connection error has occurred. Do you want to
see further details?"
If MessageBox.Show(myMessage,"Error", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) ==
DialogResult.Yes Then
TextBox1.Text = myMessage
End If

However I can't see the point in this because surely you want to display
further details in this textbox. Assuming that this code is executed in a
Catch method following an exception, you can retrieve the text of the
exception e.g.

Try
'do some db code
Catch ex As Exception
'prompt user
If MessageBox.Show("Error: A database connection error has occurred. Do
you want to see further details?","Error", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) ==
DialogResult.Yes Then
'display exception message
TextBox1.Text = ex.Message
End If
End Try

Peter
 
Back
Top