how to add the first element of first array of every record

Discussion in 'Visual Basic ( VB )' started by dee2020, Jan 28, 2008.

  1. dee2020

    dee2020 New Member

    Jan 28, 2008
    Likes Received:
    Trophy Points:
    hi friendz....

    I wanted to add the first element of first array of every record.
    Each record has two arrays,
    Each array has 5 values
    In order to do that i wrote the following code in VB...
    Option Explicit
    Private Type feedbackdata
    	FormNumberS As Integer
    	Q1(0 To 4) As Byte
    	Q2(0 To 4) As Byte
    	FormNumberE As Integer
    End Type
    Private Sub cmdDisplay_Click()
    Dim category(1 To 5) As String * 10
    Dim quantity(1 To 5) As Integer
    category(1) = "very poor"
    category(2) = "poor"
    category(3) = "good"
    category(4) = "very good"
    category(5) = "excellent"
    Dim feedback As feedbackdata
    Dim recordnum, n As Integer, a As Integer
    If (Option1.Value) Then
    a = 0
    Open "C:/student.txt" For Random As #1 Len = Len(feedback)
    For recordnum = 1 To Int(LOF(1) / Len(feedback))
    Get #1, recordnum, Q1(0)
    quantity(1) = Q1(0) + a
    a = quantity(1)
    Next recordnum
    Open "C:/analysis.txt" For Append As #2
    Print #2, category(1), quantity(1)
    End If
    I dont know why my code isnt working correctly,,,i mean its displaying the wrong sum in my "analysis.txt" file....Could you please help
  2. KiLLER

    KiLLER New Member

    Mar 2, 2008
    Likes Received:
    Trophy Points:
    Shouldn't that start from 0??

    And I still can't figure out the problem, but since you're having same five value in your "Category" why don't declare/include in your structure? Why Array? Declare then as Boolean so you can change it either True or False!

    Hope it helps.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice