check empty field(Solved)

Maybe is stupid question but i have to ask :slight_smile:
How we check if the field is empty or not ?

If textfield1.text="" then
’ it is empty
end if

If x="" then ’ x is a string
'it is empty
end if

Thank you Peter but still is no working for me.
my simple code bellow

Dim NoData as text = "No Data Available" lblengine.text = c.enginetype //this is from sqlite database (some fields is empty) if lblengine.text ="" then // check if is empty lblengine.text = NoData else do that end if
With the debugger i see if the c.enginetype have data or is empty.
When i run the app always the if lblengine.text ="" is passed
I dont get the NoData

Sorry - someone using Xojo with its text type would need to help - I just use RB and strings.

A guess - you might try the trim function.

[quote=188904:@Loannis Kolliageorgas]Thank you Peter but still is no working for me.
my simple code bellow

Dim NoData as text = "No Data Available" lblengine.text = c.enginetype //this is from sqlite database (some fields is empty) if lblengine.text ="" then // check if is empty lblengine.text = NoData else do that end if
With the debugger i see if the c.enginetype have data or is empty.
When i run the app always the if lblengine.text ="" is passed
I dont get the NoData[/quote]

The code is good. It should work.

Most probably, c.enginetype contains something, would it be space, chr(13) (return) or some control character such as chr(0).

You may want to add this line to see if c.enginetype is indeed fully empty or not

system.debuglog(str(len(c.enginetype)))

If indeed c.enginetype is completely empty it should write 0 (zero) in the IDE messages area. Any other value will mean that it contains something. Then you can try Peter’s advice to remove white space

lblengine.text = trim(c.enginetype)

or if it is some control character, investigate further by looking at the ASC value of the string.

For all intents and purposes the Text type is just a propped-up Unicode string, with fences around to prevent use without an encoding. In this instance he could has declared a string it would make no difference.

is the trim method different for ios?
if i put the bellow code i get error (it lacks an Assigns parameter)

dim s as text = c.enginedetails s.Trim =(c.enginedetails)

Try:

dim s as text
s=trim(c.enginedetails)

( That said I know nothing of IOS - I thought it was a Cisco OS :wink: )

[quote=188930:@Loannis Kolliageorgas]is the trim method different for ios?
if i put the bellow code i get error (it lacks an Assigns parameter)

dim s as text = c.enginedetails s.Trim =(c.enginedetails)[/quote]
Should be:

s = c.enginedetails.Trim

Thank you guys for the help really appreciate it.
I try the bellow methods ,but still i can’t make it to work.

dim s as text s = lbldetails.text.Trim if s = "" then lbldetails.Text = "no data" end If
or

dim s as text s = c.enginedetails.Trim if s = "" then lbldetails.Text = "no data" end If
on the debugger S value is empty and on the unicode i get (0000) (if i remember right 0000 =null?)

Unicode 0000 means S contains character code point zero, as I told you it could happen 5 posts above. Your text is not empty, it contains a null character.

You simply want to test for it :

  dim s as text
  s = c.enginedetails
  if s = "" or s = Text.FromUnicodeCodepoint(0) then
    lbldetails.Text = "no data"
  end If[/code]

Alternatively, you can simply remove it :

  
 [code] dim s as text
  s = c.enginedetails
if s = Text.FromUnicodeCodepoint(0) then 
s = ""
end if
  if s = ""  then
    lbldetails.Text = "no data"
  end If

PS : Next time you have questions about iOS code, better put it in the iOS channel.

thank you Michel if s = "" or s = Text.FromUnicodeCodepoint(0) then that was.
Yes i have read your first post,but I did not know how to get the UnicodeCodepoint.
the question is solved thank you…