Click here to Skip to main content
15,890,043 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to insert an ID number to another table column Pin
Wayne Gaylard30-Aug-12 22:24
professionalWayne Gaylard30-Aug-12 22:24 
GeneralRe: How to insert an ID number to another table column Pin
garyu8730-Aug-12 23:09
garyu8730-Aug-12 23:09 
GeneralRe: How to insert an ID number to another table column Pin
Wayne Gaylard30-Aug-12 23:19
professionalWayne Gaylard30-Aug-12 23:19 
GeneralRe: How to insert an ID number to another table column Pin
Simon_Whale30-Aug-12 23:20
Simon_Whale30-Aug-12 23:20 
GeneralRe: How to insert an ID number to another table column Pin
garyu8731-Aug-12 0:12
garyu8731-Aug-12 0:12 
GeneralRe: How to insert an ID number to another table column Pin
Wayne Gaylard31-Aug-12 0:19
professionalWayne Gaylard31-Aug-12 0:19 
GeneralRe: How to insert an ID number to another table column Pin
garyu871-Sep-12 20:22
garyu871-Sep-12 20:22 
QuestionRemove controls from a form using For Each Pin
Steven St. John30-Aug-12 5:30
Steven St. John30-Aug-12 5:30 
I suspect I can solve my problem on my own, but I'm wanting to find the most efficient solution.

I have a form with several picture boxes on it as well as a handful of other controls. I would like to cycle through the controls and, if the control is a PictureBox, remove it. I tried this:

Private Sub CreateAndDisplayTableau(ByRef frm As Form)
    'Destroy picture boxes on form
    Dim ctrl As Control
    For Each ctrl In frm.Controls
        If TypeOf ctrl Is PictureBox Then
                frm.Controls.Remove(ctrl)
        End If
    Next
End Sub


I see now that what this does is only removes half of the PictureBox. If the first PictureBox is the 4th control encountered out of 20 controls, after removal, the 5th control becomes the 4th control and, since the 4th control was already evaluated, it gets skipped.

I see that I could set the Tag property to "Mark for deletion" or something and then cycle back through and delete them that way. Or, I could use a For Next Loop and decrement the counter after removal. So I can solve this problem, I feel sure. But what is the most efficient solution?
AnswerRe: Remove controls from a form using For Each Pin
ChandraRam30-Aug-12 8:03
ChandraRam30-Aug-12 8:03 
GeneralRe: Remove controls from a form using For Each Pin
Steven St. John30-Aug-12 12:23
Steven St. John30-Aug-12 12:23 
AnswerRe: Remove controls from a form using For Each Pin
kureigu maikeru31-Aug-12 2:33
kureigu maikeru31-Aug-12 2:33 
GeneralRe: Remove controls from a form using For Each Pin
Steven St. John31-Aug-12 4:15
Steven St. John31-Aug-12 4:15 
GeneralRe: Remove controls from a form using For Each Pin
Simon_Whale31-Aug-12 4:43
Simon_Whale31-Aug-12 4:43 
GeneralRe: Remove controls from a form using For Each Pin
ChandraRam31-Aug-12 8:18
ChandraRam31-Aug-12 8:18 
GeneralRe: Remove controls from a form using For Each Pin
Simon_Whale31-Aug-12 9:04
Simon_Whale31-Aug-12 9:04 
GeneralRe: Remove controls from a form using For Each Pin
Steven St. John1-Sep-12 3:52
Steven St. John1-Sep-12 3:52 
QuestionWPF: delete item per Drag&Drop Pin
Christopher James Kleinheinz29-Aug-12 21:07
Christopher James Kleinheinz29-Aug-12 21:07 
AnswerRe: WPF: delete item per Drag&Drop Pin
Eddy Vluggen30-Aug-12 3:25
professionalEddy Vluggen30-Aug-12 3:25 
AnswerRe: WPF: delete item per Drag&Drop Pin
Bert Mitton31-Aug-12 6:33
professionalBert Mitton31-Aug-12 6:33 
QuestionVB.NET: How to merge multiple file into one CSV file? Pin
stevelk29-Aug-12 21:04
stevelk29-Aug-12 21:04 
AnswerRe: VB.NET: How to merge multiple file into one CSV file? Pin
Wayne Gaylard29-Aug-12 21:28
professionalWayne Gaylard29-Aug-12 21:28 
GeneralRe: VB.NET: How to merge multiple file into one CSV file? Pin
stevelk2-Sep-12 21:08
stevelk2-Sep-12 21:08 
AnswerRe: VB.NET: How to merge multiple file into one CSV file? Pin
Christopher James Kleinheinz29-Aug-12 21:34
Christopher James Kleinheinz29-Aug-12 21:34 
GeneralExcellent code sample Pin
David Mujica30-Aug-12 2:25
David Mujica30-Aug-12 2:25 
GeneralRe: VB.NET: How to merge multiple file into one CSV file? Pin
stevelk2-Sep-12 21:07
stevelk2-Sep-12 21:07 

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.