"Online" monitored TextBox

Discussion in 'Questions (Windows Mobile)' started by Standa, May 31, 2008.

  1. Standa

    Standa Member Licensed User

    Hi,
    I have wrote unit converter application. For starting calculate with value typed in textbox I use button control. But I want my program will calculate value immediately as I type it to textbox. Problem is, that KeyPress event at first does action programmed in KeyPress sub, and after it writes value I typed on SIP to textbox.

    For example:
    Code:
    Sub TextBox1_KeyPress (key)
     TextBox2.Text=TextBox1.Text
    End Sub
    I try to handling it with Asc(key) etc., but it is more difficult than calculating of convert himself :). I know other ways how to do it, but I want use TextBox and SIP (not own writed keyboard).
     
  2. specci48

    specci48 Well-Known Member Licensed User

    Hello Standa,

    a possible workaround could be using a timer:
    Code:
    Sub Globals
       
    'Declare the global variables here.
    End Sub

    Sub App_Start
       Timer1.Interval = 
    1
       Timer1.Enabled = 
    false
       Form1.Show
    End Sub

    Sub TextBox1_KeyPress (key)
       Timer1.Enabled = 
    true
    End Sub

    Sub Timer1_Tick
       Timer1.Enabled = 
    false
       
    ' do calculation
    End Sub
    The KeyPress events starts the timer and within the timer the TextBox1 has already the correct value.


    specci48
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    You should use the TextChanged event instead of KeyPress.
    You will need to add a reference to the door library.
    There is an example in the door manual.
     
  4. Standa

    Standa Member Licensed User

    Thank you guys. Door library is something like big gun against sparrow for my little application. So I try code with timer. :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice