Hi,
I am benefited by this forum to a very great extent. Now for the past two days trying to do some calculations in the List Box items. I have two list boxes and the first list box contains the contents of a text file. Once the user clicks the item in List Box 1 same is added in List Box 2 and removed from List Box 1. This I am able to do without any difficulty. But I need to count the number of items added in List Box 2 and also the sum of a string in the List Box 2. I am pasting the code to this mail. Kindly advise me in this regard.
Code:Private Sub lstDisplayrecord_Click() Dim Searchstring As String Dim Reasoncode As String Dim newstring As String Dim Linecnt As Integer Dim Totamt As String Searchstring = lstDisplayrecord.List(lstDisplayrecord.ListIndex) lblAccount = Mid(Searchstring, 10, 2) lblAccnum = Mid(Searchstring, 12, 15) lblTrandate = Format(Mid(Searchstring, 141, 8), "00/00/0000") lblName = Mid(Searchstring, 27, 40) lblAmount = Format(Mid(Searchstring, 116, 15) * 0.01, "#############.00") Reasoncode = InputBox("Enter Reason Code", "Reason Code", "01") 'If Reasoncode = "01" Or "02" Or "03" Or "04" Or "05" Then Totamt = Totamt + lblAmount Searchstring = Left(Searchstring, Len(Searchstring) - 2) & Reasoncode lstrejectecs.AddItem Searchstring lblrejecsamt = Format(Totamt, "#############.00") Linecnt = Linecnt + 1 lblrejecsnum = Linecnt lstDisplayrecord.RemoveItem lstDisplayrecord.ListIndex End Sub




Reply With Quote