Question How to count

vincent15mark

Member
Joined
Sep 12, 2010
Messages
5
Programming Experience
Beginner
dw.JPG

can someone put his/codes in with..
i have my own but it didn't add when i tried to put another integer on my textbox.

it will just update the first integer i put..
 
Given that this is most likely homework, how about you show us the code you do have and then we can help you fix it. Other people writing your code for you is not the way to learn. It might be the easiest way to solve a problem, but you learn the least and, if this is homework, then it's cheating too.
 
ok.. that is not what you are thinking.. i am making my project..
here is image of the project i am working of:

image.JPG

im getting the rentamount of the video, everytime i click "add to list" button from my window it will displays the title of the video in listbox and displays and add the amount of the video.
 
Here is the code for "Add to List":
VB.NET:
        Dim GridRow As DataGridViewRow = grdAvailable.CurrentRow
        lstVideos.Items.Add(CStr(GridRow.Cells.Item("Title").Value.ToString))
        txtTotalVideos.Text = lstVideos.Items.Count

        If CStr(GridRow.Cells.Item("RentAmount").Value.ToString) Then
            txtTotalAmount.Text = Val(txtTotalAmount.Text) + CStr(GridRow.Cells.Item("RentAmount").Value.ToString)
        End If
and

Here is for From "Remove From List":
VB.NET:
        With lstVideos
            If .SelectedIndices.Count > 0 Then
                For i As Integer = .SelectedIndices.Count - 1 To 0 Step -1
                    .Items.RemoveAt(lstVideos.SelectedIndices(i))
                Next

            End If
        End With
        txtTotalVideos.Text = lstVideos.Items.Count

        Dim GridRow As DataGridViewRow = grdAvailable.CurrentRow
        If CStr(GridRow.Cells.Item("RentAmount").Value.ToString) Then
            txtTotalAmount.Text = Val(txtTotalAmount.Text) - CStr(GridRow.Cells.Item("RentAmount").Value.ToString)
        End If
when i input data from listbox and in total amount and remove the data in listbox it subtract but when the listbox is already empty and click the "Remove from list" it didn't stop the..
 
Last edited by a moderator:
I haven't had time to test it but shouldn't it be more like:
VB.NET:
txtTotalAmount.Text = (Val(txtTotalAmount.Text) + GridRow.Cells.Item("RentAmount").Value).ToString
 
Back
Top