CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2001
    Location
    NC, USA
    Posts
    15

    NH w/ Img arrays and 2 timers

    Working on a project for class dealing with 4 image arrays (imgFace) and 2 timers(tmrFace1/tmrFace2). The scenerio reads like this; you have 4 images that are hidden and must use timer 1 to bring each one up after 500 milliseconds have lasped, then turn off timer one and turn on timer 2 in which timer 2 hides each image one at a time after 50mls, but it keeps going until the user clicks the exit button. Well so far I have been able to get imgFace(0,2,3) to come up with 3 blinking. Go figure. I'm stumped and need help. Here is the code I have so far.
    (Gen. Dec.)option explicit & Dim intNum as Integer

    tmrFace1
    imgFace(intNum).Visible = True
    intNum = intNum + 1
    If intNum >=3 Then
    intNum =3
    end if
    tmrFace1.enable=false
    tmrFace2.enable=true

    tmrFace2
    imgFace(intNum).Visible =False
    intNum = intNum +1
    If intNum >=3 Then
    intNum =3
    end if
    tmrFace2.enable=false
    tmrFace1.enable=true

    Now any help would be wonderful....
    And THANK YOU in advance.



  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: NH w/ Img arrays and 2 timers

    The code does what it supposed to do, maybe not what you like it to do, well look at this together

    intNum = 0
    Show face 0
    intNum = 1
    Hide Face 1 which isn't visible at the time
    intNum = 2
    Show Face 2
    intNum = 3
    Hide Face 3 which isn't visible at the time
    intNum = 4
    intNum = 3
    Show Face 3
    intNum = 4
    intNum = 3
    Hide Face 3
    intNum = 4
    intNum = 3
    Show Face 3
    intNum = 4
    intNum = 3
    Hide Face 3
    ...
    ...
    If I understand correct, it should be this

    private Sub tmrFace1_Timer()
    imgFace(intNum).Visible = true
    intNum = intNum + 1
    If intNum > 3 then
    intNum = 3
    tmrFace1.Enabled = false
    tmrFace2.Enabled = true
    End If
    End Sub

    private Sub tmrFace2_Timer()
    imgFace(intNum).Visible = false
    intNum = intNum - 1
    If intNum > 3 then
    intNum = 3
    tmrFace1.Enabled = true
    tmrFace2.Enabled = false
    End If
    End Sub




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Sep 2001
    Location
    NC, USA
    Posts
    15

    Re: NH w/ Img arrays and 2 timers

    Thanks Cakkie, but it brought them all up and did what it is suppose to do. Though I have a question, would the formatting you passed along be considered a looping program, because I thinks that's what the instructor wants, though I will turn it in the way you showed me and I am very greatful for you help. Though I can't figure out why I didn't see it for myself...I must of been having a really bad brain day... Or it could be that studing VB, C++ and Database all at once must be getting to my brain and scrambling together. 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

Featured