DDTdevelop
New member
- Joined
- Aug 17, 2011
- Messages
- 3
- Programming Experience
- 5-10
Hi all,
as always I'm here asking you a probably stupid question, but I'm upgrading an old vb 6 project, so I'd like to have all the new code more object oriented and as compact as possible.
I have a groupbox containing some textboxes. Each of them is filled with the "selecteditem.tostring" property of a listbox everytime I press a button (call it "OK BUTTON"), and everything works fine.
Code below:
Now I have to do the opposite, regarding the "CANCEL/REMOVE" button. Everytime i press it once, i need to empty the texbox.text property to a void string. It works good if i do it from the top to the bottom with code similar to the one posted before. But i need to go the opposite way, from last textbox to first. Any suggestions? In the old version of code I used a long if/then for every textbox, but it was horrible to see!
Propbably I'm simply tired and asking something very stupid, but cannot figure it out.
Thanks in advance.
as always I'm here asking you a probably stupid question, but I'm upgrading an old vb 6 project, so I'd like to have all the new code more object oriented and as compact as possible.
I have a groupbox containing some textboxes. Each of them is filled with the "selecteditem.tostring" property of a listbox everytime I press a button (call it "OK BUTTON"), and everything works fine.
Code below:
VB.NET:
For Each ctrl As Control In GroupBox1.Controls
If TypeOf ctrl Is TextBox Then
If ctrl.Text = "" Then
ctrl.Text = ListBox1.SelectedItem.ToString
Exit For
End If
End If
Next
Now I have to do the opposite, regarding the "CANCEL/REMOVE" button. Everytime i press it once, i need to empty the texbox.text property to a void string. It works good if i do it from the top to the bottom with code similar to the one posted before. But i need to go the opposite way, from last textbox to first. Any suggestions? In the old version of code I used a long if/then for every textbox, but it was horrible to see!
Propbably I'm simply tired and asking something very stupid, but cannot figure it out.
Thanks in advance.