Hi everyone! I'm having a little problem in applying changes to UDT like below. I really have no idea
vb Code:
Option Explicit Private Type ProductUDT Name As String Description As String End Type Dim Products() As ProductUDT, i As Long Dim FileLoc As String Private Sub cmdDelete_Click() List1.RemoveItem List1.ListIndex 'After the ListIndex removal, then what about the UDT?? Form_Load 'Update list End Sub Private Sub cmdAddNew_Click() 'What to do with the UDT changes? '??? Form_Load 'Update list End Sub Private Sub Form_Load() Dim Itm As String Dim Desc As String Dim counter As Integer List1.Clear FileLoc = App.Path & "\thefile.txt" Open FileLoc For Input As #1 Do Until EOF(1) counter = counter + 1 Input #1, Itm, Desc ReDim Preserve Products(1 To counter) Products(counter).Name = Itm Products(counter).Description = Desc Loop Close For i = LBound(Products) To UBound(Products) List1.AddItem Products(i).Name List1.ItemData(List1.NewIndex) = i Next Me.Caption = "Total Item : " & List1.ListCount End Sub Private Sub List1_Click() i = List1.ItemData(List1.ListIndex) lblDescription.Caption = "Description: " & vbNewLine & _ Products(i).Description End Sub
What should I do to save/ apply the changes made. Many thanks![]()




Reply With Quote