Android Question When a value changes speaks

Discussion in 'Android Questions' started by Isac, Feb 3, 2015.

  1. Isac

    Isac Active Member Licensed User

    Hi friends B4A,

    The Label4 automatically acquires a value and when
    this value changes I would make him talk, but currently is not talking.
    Maybe I have to memorize it and then compare it to?

    Code:
    If Label4.Text.Length > 0 OR Label4.Text<> Label4.Text  Then
                 tts1.Speak(Label4.Text,
    True)

    thank you
     
  2. Cableguy

    Cableguy Expert Licensed User

    Don't use a Label. Use an Edit text view and put your ts inside the text changed event.
    you will need extra coding to prevent user input.
     
    Isac likes this.
  3. Troberg

    Troberg Well-Known Member Licensed User

    I assume that you are setting the label from many places in your code, as you don't want to simply call it from there.

    My suggestion would be to add a sub to set the label and speak if need be:

    Code:
    Sub SetTTSLabel(Text as string)
      
    If Label4.Text<>Text Then
        Label4.Text=Text
        
    If Text<>"" Then
          tts1.Speak(Text,
    True)
        
    End If
      
    End If
    End Sub
    Then, simply, use

    SetTTSLabel(Text)

    instead of

    Label4.Text=Text

    everywhere you change the value of Label4 (except, of course, in SetTTSLabel).
     
    Isac and Cableguy like this.
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