Results 1 to 6 of 6

Thread: What is wrong with this?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    225

    What is wrong with this?

    End Type


    Dim People(1 to 10) as Aperson,br> For i = 1 to 10
    Print People(i).strNAME
    Next i


    People(1).strNAME = "Mary"
    People(1).intAGE = "21"
    People(1).intMASS = 80
    People(2).strNAME = "John"
    People(2).intAGE = "14"
    People(3).strNAME = "Albert Einstein"
    People(3).intAGE = "43"
    People(3).intMASS = 120


    The Dim People... keeps saying Invalid Inside Procedure and its in the usual read error text

  2. #2
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    you have to use redim

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    225
    There's something wrong with the Option Explicit thing and the < thing

  4. #4
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Ok, I think I see what you're doing. You have to add the values to the array in a procedure and declare the array outside the procedure:

    VB Code:
    1. ' Declarations of form or module
    2.  
    3. private type Person
    4.     ID as long    
    5.     strName as string
    6.     etc as etc
    7. end type
    8.  
    9. Private People(9) as person
    10.  
    11. private sub PopulatePeople
    12.  
    13. with People(0)
    14.     .ID=0  
    15.     .strName="Bob"
    16.     .etc(0)=etc.
    17. end with
    18.    
    19. with People(1)
    20.     .ID = 1
    21.     .Name = "Otto"
    22.     .etc, etc(1)=etc    
    23. end with
    24.  
    25. ' and so on and so forth
    26.  
    27. End Sub

    Are you doing the dentist app too????

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    225

    Nope

    Im not doing the dentist app we have to do a student body sorting program with their age mass and name and I try it and see if it works
















    ^Thanx^

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    225
    Is people a array What is it huh?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width