Calculations in VB6

neil , bryan , taylor Tacloban, Philippines
  • 9 years ago

    Good Day to all Expert

    I've been developing a program in visual basic 6.0 for my mother, I'm building a Database for the Information Records.

    My Problem is i can't continue my project , im stuck on calculations of this area. So im posting here maybe somebody will help me for this.

    Please take a look this image

    I'm using a DBgrid to see contents populating from my Database Table using MS-Access.

    The image above is only an example which i have to make in VB soon.

    I need a code for calculating this

    Example: RETURN + RETURN + RETURN and so on.. = Total in Textbox New + New and so on... = Total in textbox

    Note: Im not using a Number for this Im using a word/string. Eg. Return etc.

    Thanks in advance

    Regards Neil

  • 9 years ago

    Hi Neil,

    You should loop through the grid and check the content of each cell.

    dim lngNew as long
    dim lngReturn as long
    
    lngNew = 0
    lngReturn = 0
    
    For i = 1 To Grid.Rows - 1 Step 1
        if grdDetails.TextMatrix(i, 1) = "New" then
        	lngNew = lngNew + 1
        elseif grdDetails.TextMatrix(i, 1) = "Return" then
        	lngReturn = lngReturn + 1
        end if
    next i
    

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter” - Eric Raymond