Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi all,

 

I'm trying to write code to re-produce the program I have attached. I'm having problems capturing the result of a button that is clicked when the message box is displayed after pressing the 'SHOW' button. The result needs to be shown at the bottom of the form. I've tried using a 'StatusBar' but it doesn't like 'Show' being put after it. Here's what I have so far:

 

Private Sub ShowButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ShowButton.Click

Dim result As DialogResult

result = MessageBox.Show(MessageTextBox.Text, TitleTextBox.Text, buttons, icon)

If result = DialogResult.OK Then

StatusBar1.Show("OK")

Else

StatusBar1.Show("Cancel")

End If

 

End Sub

 

Thanks in advance for any replies.

 

[edit]The attachement has been removed. Please do not post binary files, but source files instead.[/edit]

Edited by mutant
  • Administrators
Posted (edited)

Rather than statusbar1.Show("OK") which shouldn't even compile as show simply displays the control and doesn't accept arguments try StatusBar1.Text = "OK".

This should work as long as ShowPanels is set to false.

If you are displaying panels then you would have to set the text via the panels collection.

 

edit: another typo

Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
Rather than statusbar1.Show("OK") which shouldn't even compile as show simply displays the control and doesn't accept arguments try StatusBar1.Text = "OK".

This should work as long as ShowPanels is set to false.

If you are displaying panels the nyou would have to set the text via the panels collection.

 

I tried putting text instead but it still doesn't like it even though ShowPanels is set to false.

 

What do u mean by "displaying panels"? I haven't done anything with panels so far.

  • Administrators
Posted

Not sure why it isn't working for you, just tried it here and it worked no problems.

 

Dim result As DialogResult
result = MessageBox.Show("Message", "caption", MessageBoxButtons.OKCancel)
If result = DialogResult.OK Then
StatusBar1.Text = "OK"
Else
StatusBar1.Text = "Cancel"
End If

 

and it displayed OK and cancel correctly.

What values are you passing in for the buttons argument? If you step through the code in the debugger does it work as expected?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (edited)

I see what I've done wrong now, I didn't have 'MessageBoxButtons.OKCancel' on the 'result=' line (I'd copied and pasted my line from some other code :o).

 

I need to add another 5 'if' statements for 5 more buttons that can be clicked, so would I just add these names at the end of the 'result= ' line (i.e. 'MessageBoxButtons.OKCancel') ??

 

 

BTW how do u get the code to appear in a white box when u put it in a post.

 

Cheers

Edited by Seb
  • Leaders
Posted
Use the [vb] blah [/code] tags. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...