Results 1 to 4 of 4

Thread: More Array Questions

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214

    More Array Questions

    I am having more troubles with arrays. It won't let me move text from one label to another. Here is my code for clicking the button:

    Code:
    For i = 0 to 9
    If Slots(i) = true then 
    backpack.slot(i + 1).caption = stats.lblweapon.caption'Slots go from 1 to 10, so i+1 is needed
    end if
    next i
    My declarations:

    Code:
    dim Slots(9) as string
    And my Form_Load

    Code:
    for i = 0 to 9
    if backpack.slot(i + 1).caption = "" then slots(i) = true 'The backpack slot is empty, so the boolen = true
    end if
    next i
    Am I doing anything wrong?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    What are BackPack, Slot and Stats? Are they Forms? Control Arrays?

  3. #3
    Fanatic Member
    Join Date
    Feb 2003
    Location
    Los Angeles, CA
    Posts
    681
    watch the typing of your 'slots' array: you declare it as string, but you try to use it as boolean.

    dim Slots(0 to 9) as boolean

    for i = 0 to 9
    if backpack.slot(i + 1).caption = "" then
    slots(i) = true
    end if
    next i

    For i = 0 to 9
    If Slots(i) then
    backpack.slot(i + 1).caption = stats.lblweapon.caption
    end if
    next i

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    So I dim it like this:

    Slots(0 to 9) as Boolean?

    Thanks, I think that may work. I just remembered that I am getting a type mismatch error. Dumb meh. Thanks again.

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