CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    A little problem....

    this code is in the timer

    max = max + 1
    Text1.text = mid("blah", 1, max)
    If max = 20 then Timer5.Enabled = false



    Problem is that when timer being enabled, it just types in one first letter..."b" and stops, when it should keep on typing in whole word "blah"
    I tried to remove If max = 20 Then Timer5.Enabled = False, still no effect....Please help

    Thank You


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: A little problem....

    Hi

    You'll need to make the 'max' variable 'static' in that routine (so that it retains it's value between calls).

    eg:


    static max as Integer

    max = max + 1
    Text1.Text = mid("blah", 1, max)
    If max = 20 then Timer5.Enabled = false




    I'd also recommend that you change the last line to something like :



    If max = 20 then
    max = 0
    Timer5.Enabled = false
    End if




    - so that the 'max' value get's reset again (otherwise it'll keep on going up & up).


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

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