Results 1 to 9 of 9

Thread: Help with timer???

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Posts
    237

    Help with timer???

    I want to make the Text1 box flipping donw gradually after pressing a the command button. What's wrong with the following code?

    VB Code:
    1. Private Sub Command1_Click()
    2.  Text1.Visible = True
    3.  Timer1.Enabled = True
    4.  Timer1.Interval = 1000
    5. End Sub
    6.  
    7. Private Sub Timer1_Timer()
    8. Dim i As Integer
    9. For i = 1 To 2000
    10.    Text1.Height = i
    11.    If i = 2000 Then
    12.    Exit Sub
    13.    End If
    14. Next i
    15. End Sub

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Help with timer???

    What do you mean by "Flipping Down"?

    In you example, the TextBox will grow.

  3. #3
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Help with timer???

    Keep in mind that sizes are set in Twips, and 15 twips makes one pixel.

    The code you have would take 2000 seconds for the text box to have a height of 133 pixels, which is a looooong time.

    And the Exit Sub is not needed. The loop will stop when i=2000 anyway, and since there's nothing after the loop, the sub will end.

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Help with timer???

    Not really sure what you mean...

    Something like this?

    VB Code:
    1. Private Sub Command1_Click()
    2.     Timer1.Interval = 10
    3.     Timer1.Enabled = True
    4. End Sub
    5.  
    6. Private Sub Timer1_Timer()
    7.     Timer1.Enabled = False
    8.    
    9.     If Text1.Height > 285 Then
    10.         Text1.Height = Text1.Height - 10
    11.     End If
    12.    
    13.     Timer1.Enabled = Not Text1.Height <= 285
    14. End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Posts
    237

    Re: Help with timer???

    I want the Text Box to gradually expand down upto height of 2000.

  6. #6
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Help with timer???

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Timer1.Enabled = True 'start the expanding
    4.  
    5. End Sub
    6.  
    7. Private Sub Form_Load()
    8.  
    9.     Text1.Height = 1
    10.     Timer1.Interval = 67 'speed of change
    11.     Timer1.Enabled = False
    12.    
    13. End Sub
    14.  
    15. Private Sub Timer1_Timer()
    16.  
    17.     Text1.Height = Text1.Height + 15 'increases size of text box
    18.     If Text1.Height >= 2000 Then Timer1.Enabled = False 'turns timer off when target height is reached
    19.    
    20. End Sub

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Help with timer???

    Text1.Height = Text1.Height - i

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Posts
    237

    Re: Help with timer???

    Many thanks for all of you for help .. special thanks for timeshifter

  9. #9
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Help with timer???

    Anytime. We're here to help.

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