Hi everyone. I could use some help because I'm kind of a newbie with VBA. Im designing this application were you enter a barcode to text box and search a sheet for an identical match then display info in a list box and populates two text boxes "txtbox' & i and "txtbox0" & i to enter the passenger weight and bag weight. So I created an array of textboxes. The problem is with the removing a selection. The logic is based on that I name my textboxes in sequential order to be able to remove them by referring to (i) as following<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
Removal code<o></o>
ListBox1.RemoveItem ListBox1.ListIndex<o></o>
'because my txtboxes start at 1 I add 1 to the list index which starts at 0<o></o>
i = ListBox1.ListIndex + 1<o></o>
<o></o>
<o></o>
My problem is I can't get the code to repeat for a second removal. the row is deleted but the textboxes index are all messed up. I tried renaming the textbox but failed miserably. I also tried re-index the array but also failed. I have been googling this matter for three days now and can't find a solution. Maybe I’m doing it wrong. Really any help here would be marvelously appreciate. I hope I explained my problem clearly.<o></o>
Thanks in advance
Shreef
Code:
<o:p></o:p>
Code:
[COLOR=black][FONT=Verdana]'adding row to listbox<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]v = ListBox1.ListCount<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set tbarray(v) = Frame2.Controls.Add("Forms.TextBox.1", "txtbox" & v)<o:p></o:p>[/FONT][/COLOR]
Removal code<o></o>
ListBox1.RemoveItem ListBox1.ListIndex<o></o>
'because my txtboxes start at 1 I add 1 to the list index which starts at 0<o></o>
i = ListBox1.ListIndex + 1<o></o>
Code:
<o:p></o:p>
Code:
[COLOR=black][FONT=Verdana] If i > 0 And i < 13 Then[/FONT][/COLOR]
[FONT=Verdana][COLOR=black]'remove the textboxs[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Frame2.Remove ("txtbox" & i )[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Frame2.Remove ("txtbox0" & )[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] For f = i + 1 To 11[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] If (Not tbarray(f) Is Nothing) And (Not TBarray2(f) Is Nothing) Then[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Mytop = tbarray(f).Top[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] tbarray(f).Top = Mytop - 12[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] TBarray2(f).Top = Mytop - 12[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] End If[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Next f[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] End If[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] End If[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]End Sub<o:p></o:p>[/COLOR][/FONT]
<o></o>
My problem is I can't get the code to repeat for a second removal. the row is deleted but the textboxes index are all messed up. I tried renaming the textbox but failed miserably. I also tried re-index the array but also failed. I have been googling this matter for three days now and can't find a solution. Maybe I’m doing it wrong. Really any help here would be marvelously appreciate. I hope I explained my problem clearly.<o></o>
Thanks in advance
Shreef