简体   繁体   中英

Delphi Android, making first letters uppercase problem. But not on VCL

I tried to look at some steps about making the word automatically become uppercase letters in the first letter. I used to use it on VCL and it works very well, but why on mobile applications it doesn't work properly. I use this code, but in edit2, the result is that I lost the first letter and the words start with the second letter that I entered in edit1, even though it starts with uppercase. Maybe someone can help me. Thank you very much

    var i, j : integer;
        s, edt2 : string;
Procedure
         j := length(edt1.Text);
            s := '';
            for i := 2 to j do
            begin
              s := s + LowerCase(edt2.Text[i]);
            end;
            edt2 := UpperCase(edtProduk.Text[1]) + s;

In Delphi mobile platforms you have to understand that strings are zero-based (just like arrays).

To avoid issues, if you want to access the first index and last index of a string in a cross platform safe way, use the System.Low and System.High intrinsics on the string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM