Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Location
    hertfordshire
    Posts
    2

    Question Unanswered: Help with with some VB6 coding

    Hiya

    I have a problem, that I am hoping I can get help with.

    I have a program that has 5 lights that are different colors (these are my disco lights), a timer and 2 text boxes. One text box is for a password and when the password is input correctly my box changes color and I have got this to work. But what I need to do after that is to get the textbox to clear the password using a For...Next statement with a 1-2 second delay. I then need to set this text box visibility to false. I know how to do this using txtpassword.visible = false but after this, this is where my second text box comes into play.

    I have a variable called countnumber and loopnumber, what i need to do, is to populate my second text box with a figure - my instructions advise that I need to use an inputbox$ function to output a prompt and obtain a figure from the user and place the string in the variable loop number, (this figure specifies how many times the disco lights run through its sequence).

    I then need to use a loop to set the visability of my disco lights to true and to get my timer to enabled and to call my timer sub procedure.

    Is there anyone that can help me with this, I am just struggling in getting started, I think I know bits of it, but it is how to put all of this together.

    I hope this makes sense

    Any help, gratefully accepted......

    Thanks

    Taz
    Last edited by Tazmania; 01-15-06 at 15:28. Reason: change title

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    To add the delay between entering the password and clearing the password...

    Add a timer to your form, which is NOT enabled. Give it an interval of 1500 (1.5 seconds) And, for this example, call it tmr_1_Shot. Then, double click the timer, and add the following code...
    Code:
    Private Sub tmr_1_Shot_Timer()
      ' First, turn the timer off again
      me.tmr_1_Shot.Enabled = False
      '
      ' Then, clear the password
      me.txtPasswod.Text = ""
      'or, just to make it not visible...
      me.txtPassword.Visible = False
    
    End Sub
    To use the timer, in your code where you validate the password as entered, just add the following to enable the one-shot timer

    Code:
    me.tmr_1_Shot.Enabled = True
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    In a similar vein, add a different timer to handle the flashing you were talking about. However, in IT'S timer event, add a static variable to track the number of timer events that have passed.

    Code:
    Private Sub tmr_Disco_timer
    
      ' Increment the loop number & check to see how many times have passed
      LoopNumber = LoopNumber + 1
      
      If LoopNumber > CountNumber then
        ' Stop the Disco Timer
        me.tmr_Disco.Enabled = False
        ' and, reset the counter for the next time
        LoopNumber = 0
      Else
        ' Flash The Lights
        ' Whatever your code is to flash lights
      End If
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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