Click here to Skip to main content
16,006,845 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questiondatatable in vb.net Pin
vipinpaliwal198012-Apr-06 19:43
vipinpaliwal198012-Apr-06 19:43 
AnswerRe: datatable in vb.net Pin
Dave Kreskowiak13-Apr-06 7:16
mveDave Kreskowiak13-Apr-06 7:16 
QuestionNewbie - Can anyone help? Need lots of it. Pin
UBigDummie12-Apr-06 19:07
UBigDummie12-Apr-06 19:07 
AnswerRe: Newbie - Can anyone help? Need lots of it. Pin
J4amieC12-Apr-06 22:19
J4amieC12-Apr-06 22:19 
Questionremove buttons for lists Pin
surfer.chic.robbie12-Apr-06 17:26
surfer.chic.robbie12-Apr-06 17:26 
AnswerRe: remove buttons for lists Pin
Dave Kreskowiak13-Apr-06 7:20
mveDave Kreskowiak13-Apr-06 7:20 
GeneralRe: remove buttons for lists Pin
surfer.chic.robbie14-Apr-06 0:40
surfer.chic.robbie14-Apr-06 0:40 
GeneralRe: remove buttons for lists Pin
Dave Kreskowiak14-Apr-06 1:32
mveDave Kreskowiak14-Apr-06 1:32 
Easy, but with a hidden gotcha. Each the index of each selected item is contained in the ListBox's SelectedIndicies property. All you have to do is go through this list using For/Next, NOT For Each/Next!!, and remove each item from the Items collection at the index listed in SelectedIndicies.

There's the catch though! You have to go through the SelectedIndicies backwards! If you don't, you'll end up with an IndexOutOfRangeException. This is because as you remove items from the ListBox, the size of the collection of Selectedindicies changes. Say you have 10 items selected. At the beginning of the For/next loop, you'll be counting from 0 to 9. But, after you remove the first item, the upper limit of the Selectedindicies collection will be 8, not 9. And so on until your loop, still counting to 9, passes the upper limit of the Selectedindicies collection.
Dim i As Integer
For i = ListBox1.SelectedIndices.Count - 1 To 0 Step -1
    ListBox1.Items.RemoveAt(ListBox1.SelectedIndices(i))
Next



Dave Kreskowiak
Microsoft MVP - Visual Basic

QuestionStructure Array Pointers Pin
Ed Hunt ,Jr.12-Apr-06 14:40
Ed Hunt ,Jr.12-Apr-06 14:40 
AnswerRe: Structure Array Pointers Pin
Dave Kreskowiak12-Apr-06 15:28
mveDave Kreskowiak12-Apr-06 15:28 
Questionconfiguration file Pin
SVb.net12-Apr-06 11:38
SVb.net12-Apr-06 11:38 
AnswerRe: configuration file Pin
Dave Kreskowiak12-Apr-06 15:23
mveDave Kreskowiak12-Apr-06 15:23 
AnswerRe: configuration file Pin
nguyenvhn12-Apr-06 23:03
nguyenvhn12-Apr-06 23:03 
GeneralRe: configuration file Pin
Dave Kreskowiak13-Apr-06 2:26
mveDave Kreskowiak13-Apr-06 2:26 
QuestionHelp needed with multi column Combobox? Pin
Rashar12-Apr-06 9:39
Rashar12-Apr-06 9:39 
AnswerRe: Help needed with multi column Combobox? Pin
Dave Kreskowiak12-Apr-06 15:17
mveDave Kreskowiak12-Apr-06 15:17 
Questionhow to highlight only the selected text in a List view Items and sub items? Pin
Ruki7612-Apr-06 8:35
Ruki7612-Apr-06 8:35 
AnswerRe: how to highlight only the selected text in a List view Items and sub items? Pin
Dave Kreskowiak12-Apr-06 17:18
mveDave Kreskowiak12-Apr-06 17:18 
QuestionRe: how to highlight only the selected text in a List view Items and sub items? Pin
Ruki7613-Apr-06 0:39
Ruki7613-Apr-06 0:39 
AnswerRe: how to highlight only the selected text in a List view Items and sub items? Pin
Dave Kreskowiak13-Apr-06 2:25
mveDave Kreskowiak13-Apr-06 2:25 
Questionhow to highlight only the selected text in a List view Items and sub items? Pin
Ruki7612-Apr-06 8:34
Ruki7612-Apr-06 8:34 
Questionmasked textbox for webform Pin
seekerOfSeekers12-Apr-06 8:04
seekerOfSeekers12-Apr-06 8:04 
QuestionCursor Image Pin
Peter B12-Apr-06 6:16
Peter B12-Apr-06 6:16 
AnswerRe: Cursor Image Pin
Dave Kreskowiak12-Apr-06 15:07
mveDave Kreskowiak12-Apr-06 15:07 
GeneralRe: Cursor Image Pin
Peter B13-Apr-06 2:13
Peter B13-Apr-06 2:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.