Results 1 to 5 of 5

Thread: Array in Form Load Event doesn't work!

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    63

    Array in Form Load Event doesn't work!

    I have made a form and put 5 Combo Boxes in there.

    In the Form Load event, I populated all those Combo Boxes with figures etc..

    After that, I stated some arrays and then when I try to run it, it doesnt work. Message comes up saying "Expected Array".

    Here is the code:

    Private Sub Form_Load()

    'Populate the Runway Combo Box

    cboRwy.AddItem "Runway 10"
    cboRwy.AddItem "Runway 28"
    cboRwy.ListIndex = 0

    'Populate the Flap Combo Box

    cboFlap.AddItem "Flap 5"
    cboFlap.AddItem "Flap 15"
    cboFlap.ListIndex = 0

    'Populate the Wind Combo Box

    For W = -10 To 20
    cboWind.AddItem (TW) & " Knots"
    Next W

    cboWind.ListIndex = 10

    'Populate the Temperature Combo Box

    For T = -10 To 40
    cboTemp.AddItem (T)
    Next T
    cboTemp.ListIndex = 22

    'Populate the QNH Combo Box

    For Q = 980 To 1050
    cboQnh.AddItem (Q)
    Next Q
    cboQnh.ListIndex = 30

    'Populate the EAI Combo Box

    cboEAI.AddItem "Anti Ice ON"
    cboEAI.AddItem "Anti Ice OFF"
    cboEAI.ListIndex = 0


    A = -10
    For f = 1 To 5
    R10F5Array(0, f) = A
    Debug.Print R10F5Array(0, f)
    A = A + 5
    Next

    B = -10
    For f = 1 To 11
    R10F5Array(f, 0) = B
    Debug.Print R10F5Array(f, 0)
    B = B + 5
    Next

    'Populate the internal grid array
    'for Rwy 10, Flap 5

    R10F5Array(1, 1) = 18460
    R10F5Array(1, 2) = 19200
    R10F5Array(1, 3) = 19850
    R10F5Array(1, 4) = 20320
    R10F5Array(1, 5) = 20690

    R10F5Array(2, 1) = 18350
    R10F5Array(2, 2) = 19110
    R10F5Array(2, 3) = 19750
    R10F5Array(2, 4) = 20240
    R10F5Array(2, 5) = 20630

    R10F5Array(3, 1) = 18240
    R10F5Array(3, 1) = 19020
    R10F5Array(3, 1) = 19670
    R10F5Array(3, 1) = 20150
    R10F5Array(3, 1) = 20570

    R10F5Array(4, 1) = 18120
    R10F5Array(4, 1) = 18910
    R10F5Array(4, 1) = 19570
    R10F5Array(4, 1) = 20050
    R10F5Array(4, 1) = 20490

    etc..

    End Sub

    Do you know what the problem is?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Did you Dim the array? Given the code, that's the only thing I can see.....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    63
    Private Sub Form_Load()

    Dim R10F5Array As Integer
    Dim R10F15Array As Integer
    Dim R28F5Array As Integer
    Dim R28F15Array As Integer

    'Populate the Runway Combo Box

    cboRwy.AddItem "Runway 10"
    cboRwy.AddItem "Runway 28"
    cboRwy.ListIndex = 0

    I've dimmed it but still says Expected Array

    it highlights the first instance of using the array:
    A = -10
    For f = 1 To 5
    R10F5Array(0, f) = A
    Debug.Print R10F5Array(0, f) ' here
    A = A + 5
    Next

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by Jetheat
    Private Sub Form_Load()

    Dim R10F5Array As Integer
    Dim R10F15Array As Integer
    Dim R28F5Array As Integer
    Dim R28F15Array As Integer

    'Populate the Runway Combo Box

    cboRwy.AddItem "Runway 10"
    cboRwy.AddItem "Runway 28"
    cboRwy.ListIndex = 0

    I've dimmed it but still says Expected Array

    it highlights the first instance of using the array:
    A = -10
    For f = 1 To 5
    R10F5Array(0, f) = A
    Debug.Print R10F5Array(0, f) ' here
    A = A + 5
    Next
    That's not an array. It should be something like this

    VB Code:
    1. Dim R10F5Array(4, 5) As Integer  'For example... check each bound
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    63
    Thanks for that

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