PureSc0pe Posted April 22, 2004 Posted April 22, 2004 If you choose Yes on the messagebox, I want it to run ListBox6.Items.Remove(ListBox6.Text) If you choose no, I want to exit sub... Shouldn't this work? MessageBox.Show("Are you sure you want to clear your Ban List?", "CoD Administration .Net", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) If DialogResult.Yes = True Then ListBox6.Items.Remove(ListBox6.Text) Else Exit Sub End If Quote It's not impossible, it's Inevitable.
*Experts* jfackler Posted April 22, 2004 *Experts* Posted April 22, 2004 If you choose Yes on the messagebox, I want it to run ListBox6.Items.Remove(ListBox6.Text) If you choose no, I want to exit sub... Shouldn't this work? MessageBox.Show("Are you sure you want to clear your Ban List?", "CoD Administration .Net", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) If DialogResult.Yes = True Then ListBox6.Items.Remove(ListBox6.Text) Else Exit Sub End If Assuming you want to remove the selected item: If MessageBox.Show("Are you sure you want to clear your Ban List?", "CoD Administration .Net", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then ListBox6.Items.Remove(ListBox6.SelectedItem) Else Exit Sub End If Jon Quote
PureSc0pe Posted April 22, 2004 Author Posted April 22, 2004 Assuming you want to remove the selected item: If MessageBox.Show("Are you sure you want to clear your Ban List?", "CoD Administration .Net", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then ListBox6.Items.Remove(ListBox6.SelectedItem) Else Exit Sub End If Jon Thanks, works... :D Quote It's not impossible, it's Inevitable.
*Experts* Nerseus Posted April 22, 2004 *Experts* Posted April 22, 2004 To be clear on why your original code didn't work, the way you were using "DialogResult" was a bit off. The "DialogResult" your program was reading was from the form (which has a DialogResult property). Your code was essentially: If Me.DialogResult.Yes = True Then... As a default, the form's DialogResult is Cancel (I think) unless you set it or have a button's DialogResult property set and you're within the click event - not really that important, just thought I'd elaborate on my elaboration. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
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.