Android Question Missing function?

Discussion in 'Android Questions' started by TyneBridges, Jul 18, 2015.

  1. TyneBridges

    TyneBridges Member Licensed User

    Another very basic one, I'm afraid.

    The link http://www.b4x.com/android/help/core.html#string_length says that "length" is a core string function. However, the following will not compile

    Dim D As String * 2, M As String * 2, Y As String * 4
    Dim StartDt As String, EndDt As String, L As Int
    ..
    Y = EY.Text
    ..
    If D <> "" And M <> "" And Y <> "" Then StartDt = Y & "-" & M & "-" & D
    L = Length(Y)

    It gives the error "Undeclared variable 'length' was used before it was assigned any value".

    It's not a variable - it's meant to be built in...

    Any ideas?

    Thanks
     
  2. Roycefer

    Roycefer Well-Known Member Licensed User

    Length() is a member function of the String object. Do Y.Length instead of Length(Y).
     
  3. klaus

    klaus Expert Licensed User

    What is this supposed to do ?
     
  4. TyneBridges

    TyneBridges Member Licensed User

    Create a string 2 characters in length?
     
  5. TyneBridges

    TyneBridges Member Licensed User

    Thanks for the info, Roycefer!
     
  6. DonManfred

    DonManfred Expert Licensed User

    No. A string is a string and can hold as many characters as you want. It is dynamic.
     
    TyneBridges likes this.
  7. Roycefer

    Roycefer Well-Known Member Licensed User

    My pleasure. It also looks like you're trying to manually format a date String. I would recommend against doing that and instead look at the DateTime object and all its member functions. You can set up custom DateTime formats (or use pre-configured ones) and it comes with parsing functions and lots of other helpful stuff. It's much more robust than trying to put together a brittle ad hoc one-time solution.
     
    TyneBridges likes 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