Jonnystudent
New member
- Joined
- Aug 23, 2010
- Messages
- 1
- Programming Experience
- Beginner
Hi Guys and Gyals. I'm a newbie here so please be gentle. I'm in the process of completing a project but I'm finding it difficult to accomplish one thing. I have built a program in where I have to add and remove items from two listboxes. Listbox1 consists of a file which I have picked up on my C:/. Within this file, are different lines of items. At the end of the item line is a figure. I have a textbox in where when someone adds the an item from listbox1 to listbox2. On clicking the add button, it will add the total which was in the file. If I add more items, it will give me a running total of the items I have added to listbox2.
Now, I'm bamboozled in how to subtract the items from listbox2 with the remove button. So that when a user wants to remove an item that they currently placed in Listbox2. On pressing remove it will subtract the running total from the item which has been removed..
Here is my code in where I add products to the textbox. I have two other text boxes which I use to have these running totals. FYI, Textbox where value is outputted is Textbox5. Textbox6 is used to refresh the data and the other textbox is named 'Total'.
Any help would be greatly appreciated.
Cheers,
Jonah
Now, I'm bamboozled in how to subtract the items from listbox2 with the remove button. So that when a user wants to remove an item that they currently placed in Listbox2. On pressing remove it will subtract the running total from the item which has been removed..
Here is my code in where I add products to the textbox. I have two other text boxes which I use to have these running totals. FYI, Textbox where value is outputted is Textbox5. Textbox6 is used to refresh the data and the other textbox is named 'Total'.
VB.NET:
Public Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ListBox1.SelectedIndex < 0 Then
MsgBox("Please select a Batch")
Else : TextBox5.Text = ListBox1.SelectedItem
Dim obWriter As New System.IO.StreamWriter("C:\Scheduler\Batchsort\Len1.txt")
obWriter.Write(TextBox5.Text)
obWriter.Close()
TextBox5.Clear()
Dim FILE_NAME2 As String = "C:\Scheduler\Batchsort\Len1.txt"
Dim so As New System.IO.StreamReader(FILE_NAME2)
Dim Len As String
Len = so.ReadLine
Dim length = Len.Substring(29, 6)
ListBox2.Items.Add(ListBox1.SelectedItem)
Dim Total = Len.Substring(29, 6)
running_tot_length = running_tot_length + Val(Total)
TextBox5.Text = running_tot_length
TextBox6.Refresh()
so.Close()
End If
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
Any help would be greatly appreciated.
Cheers,
Jonah