No announcement yet.

String to Int Conversion

  • Filter
  • Time
  • Show
Clear All
new posts

    String to Int Conversion

    Hi, so i'm working on a project and i have an external database which i get a stored value from, that value is a string and when i try to convert it to an Int it removes the leading 0, if the leading number is not 0 it works perfectly fine.

    So basically i need a way to keep the leading 0 but everything i have tried has failed

    Any help is appreciated - Ryan

    Not sure what you mean, is it not possible to add this to an integer array instead? And pick indexes from that


      Op wants to store 01, 02, 03 in the int rather than 1,2, 3.

      Perhaps, when you fetch the value back from the int variable (for text processing I assume), check if it's less than 10 and build a string from int.


        I am not sure of your trouble but If you mean that when you get 015 in your string, int returns 15, this is a normal thing for numbers. 0 is always ignored. If you need the 0 absolutely, you have to stay with string.

        Edit : As Everynone said, if you need maths then you can go int and come back to string with for example saving length but as long work needs to be really usefull imho
        Last edited by Fen; 07-01-2018, 05:12 AM.