Label text

In my text changed of event hadler, I have this line of codes to user’s field.

If me.text = “tttt“ then
Pagee.show
Else
Label.text = “wwwwwww“
End if

But my challenge is,I still want to change the label text if user enter text in another attempt and yet another. I don’t want a stagnant label text of “wwwwww“ but a changing label text in 1st to 5th attempt. Help

use label.caption =“wwwww”, because (.text) is for TEXTFIELD object

define a global variable as a counter

counter=counter+1
label.caption="This is attempt #"+str(counter)

Thanks to great teachers @Ruben Dieminger and Dave S but sirs, how do i define global variable. That is new to me and i know i have a long way to go with my project. Thanks

Add a property to the window or to a Module.

Thanks to all my great teachers,your student is grateful.

But if am to count the numbers of text entered by user to show a strong password or otherwise,I used
Dim text as integer but that is not just functioning. @Dave S,can counter+1 line of code work for it as well? Thanks sir.

I suggest you step back from you project, and do some reading in the XOJO supplied documents and come back again.

I feel you don’t have the proper conceptual background to understand the direction that we are attempting to show you.

In your first post… you mentioned “label.text”
Label is an object (or control) and since “LABEL” is the type, the actual name must be “differenct” such as “label1”
Text is a property of a label, or as Rueben pointed out, the correct property name is “caption”

your statement of “DIM TEXT AS INTEGER”
creates a variable that is an Integer Datatype, and is named “text” … (legal, but I’d pick a name that is more meaningful)

However, if you wish to use the tip I provided, then you need to have somewhere “DIM COUNTER AS INTEGER”

you need to garner an understanding of what a control is (label for example), what propertys are (in this case caption), and then individual variables (in this case “COUNTER”), but just as important is the concept of Scope. For if any of these are defined in the incorrect scope, they will not be accessible by other parts of the program. I am going to leave learning about scope as an exercise for you to research.

  1. To define a global vble to use in all the System, define in APP

App -> properties
example:

Name: mDatabaseLocalPath
type: String
Default:
Scope: Public

to use this definition in any windows are: Example window1:

Window1->Eveng Handlers -> Open

  myDBname =  "circulo." + App.genMdb_Version+".sqlite"
  myPath = rtrim(App.mDatabaseLocalPath)
  if right(myPath,1)="\" then
    myDatabse  = myPath + myDBname
  else
    myDatabse  = myPath + "\"+myDBname
  end if

in simple, use “app.xxxxyourdefinitionsxxx”

  1. This definition are similar in a windows properties
    in this case, not use “app.” only the vble name

:slight_smile:

Actually, technically, a property in App accessible from elsewhere is set as public.

A truly global property is typically created in a module an set as Global.

Nevertheless, I do not think such subtleties are necessary at this point for Adesiyan who definitely seem to need learning of the basis before anything else. I would recommend reading first and foremost Introduction to Programming at https://xojo.com/learn/

[quote=218208:@adesiyan segun]But if am to count the numbers of text entered by user to show a strong password or otherwise,I used
Dim text as integer but that is not just functioning. @Dave S,can counter+1 line of code work for it as well? Thanks sir.[/quote]
No. That is a different situation and requires a different, although simpler, solution. Use Len(me.Text) to get the length of text entered by the user (in the TextChange event).

@Dave S,you are very right sir, thanks for that.
@Ruben Dieminger,@Michel Bujardet and @Tim Hare. A very big thank you to you all for your time. I learn faster discussing with masters. Thanks

Sorry, but that is nonsense.

Firstly, you don’t need “masters” to learn the basics.

Secondly, the difference between your first and last post is 9 hours. In those 9 hours you could have read at least book 1 of the Xojo documentation and learned much more than was discussed here. So you are not making good use if your time, not to mention other people’s time.

Ruben’s comment is wrong. Label.Caption has been deprecated. You should indeed use Label.Text. See Label.Caption, section “Controls implementing the Caption property”.

@Ruben Dieminger,i was using label text and it is working very well but my attempt with label caption was not just working. Thanks to all.