Results 1 to 6 of 6

Thread: Question about For next and variable

  1. #1

    Thread Starter
    Member fly_dragoon's Avatar
    Join Date
    Oct 2001
    Location
    Canada
    Posts
    47

    Question Question about For next and variable

    Hi everyone!!!

    Here is my problem:

    I used the code of a graphic filther that I found on this site
    (here's the code) |
    |
    V

    For x = 1 To FrmDessin1.PictureDessin.ScaleHeight - 3
    For y = 1 To FrmDessin1.PictureDessin.ScaleWidth - 3
    pixval = FrmDessin1.PictureDessin.Point(y+ CInt(Rnd * 10), x + CInt(Rnd * 10))
    red_val = "&h" & Mid$(CStr(Hex(pixval)), 5, 2)
    green_val = "&h" & Mid$(CStr(Hex(pixval)), 3, 2)
    blue_val = "&h" & Mid$(CStr(Hex(pixval)), 1, 2)
    If red_val = "&h" Then red_val = "&h0"
    If green_val = "&h" Then green_val = "&h0"
    If blue_val = "&h" Then blue_val = "&h0"
    FrmDessin1.PictureDessin.PSet (y, x), RGB(red_val, green_val, blue_val)
    Next
    Next

    Now 1st when I used it, it worked fine but....I did something later
    and now my Application won't compile. The error said that the variable x and y were not defined.

    could someone tell me what could I have done wrong and how to
    make it work again?
    Waiting in the shadow...learning and learning....perfectionning my programming skill....I'll see the fall of Bill Gates....and soon enought....HE WILL SEE MY RISING AND I WILL BE HIS BOSS.....and I will RULE THE WORLD!!! MUHAHAHA........(sorry sometime it happen to me.... if it happen again, don't mind me!!!)

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    i thought it would have been pretty obvious.....

    put this at the top of the sub

    Dim x as long
    dim y as long
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Try using


    Next Y
    Next X


    If thats not the problem then you should dim the variables


    Dim X as Interger, Y As integer
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  4. #4

    Thread Starter
    Member fly_dragoon's Avatar
    Join Date
    Oct 2001
    Location
    Canada
    Posts
    47

    Smile to BuggyProgrammer

    It's the first thing I did but if I do that it ask me the same thing with pixval and the other's

    (the code work on another program I made and the original code doesn't need to dim any variable)

    I'll put a demo to show you that it work without any dimed variable

    I think elsewhere on my program code I did something that stopped the filther from working...but I don't know what....do you know what could I have done wrong?
    Waiting in the shadow...learning and learning....perfectionning my programming skill....I'll see the fall of Bill Gates....and soon enought....HE WILL SEE MY RISING AND I WILL BE HIS BOSS.....and I will RULE THE WORLD!!! MUHAHAHA........(sorry sometime it happen to me.... if it happen again, don't mind me!!!)

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    check at the very top of you form and see if Option Explicit is there
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  6. #6

    Thread Starter
    Member fly_dragoon's Avatar
    Join Date
    Oct 2001
    Location
    Canada
    Posts
    47

    thank's

    I found 2 problems:

    -the Option explicit was changed of place somehow

    -a piece of code that was using the same variable

    thank's now it work again
    Waiting in the shadow...learning and learning....perfectionning my programming skill....I'll see the fall of Bill Gates....and soon enought....HE WILL SEE MY RISING AND I WILL BE HIS BOSS.....and I will RULE THE WORLD!!! MUHAHAHA........(sorry sometime it happen to me.... if it happen again, don't mind me!!!)

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