Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

It's not impossible, it's Inevitable.
  • *Experts*
Posted
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

Posted
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

It's not impossible, it's Inevitable.
  • *Experts*
Posted

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

"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

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...