Seb Posted November 26, 2003 Posted November 26, 2003 (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 November 26, 2003 by mutant Quote
Administrators PlausiblyDamp Posted November 26, 2003 Administrators Posted November 26, 2003 (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 November 26, 2003 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Seb Posted November 26, 2003 Author Posted November 26, 2003 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. Quote
Administrators PlausiblyDamp Posted November 26, 2003 Administrators Posted November 26, 2003 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? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Seb Posted November 26, 2003 Author Posted November 26, 2003 (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 November 26, 2003 by Seb Quote
Leaders Iceplug Posted November 26, 2003 Leaders Posted November 26, 2003 Use the [vb] blah [/code] tags. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.