want to change text into integer

shwetashweta Member Posts: 94
i have a string and i want last 5 characters and want to convert into integer.

Comments

  • AlbertvhAlbertvh Member Posts: 516
    hi

    You could do the following
    EVALUATE(MyInteger,COPYSTR(MyString,STRLEN(MyString) - 5));
    

    Hope this helps

    Albert
  • JedrzejTJedrzejT Member Posts: 267
    Hi

    Try this

    IF EVALUATE(intvariable,COPYSTR(txtvariable,LEN(txtvariable)-5,5)=FALSE THEN
    intvariable:=0;

    Regards
  • kinekine Member Posts: 12,562
    JedrzejT wrote:
    Hi

    Try this

    IF EVALUATE(intvariable,COPYSTR(txtvariable,LEN(txtvariable)-5,5)=FALSE THEN
    intvariable:=0;

    Regards

    TIP: You do not need to compare BOOLEAN result with TRUE or FALSE... ;-)
    IF not EVALUATE(intvariable,COPYSTR(txtvariable,LEN(txtvariable)-5,5) THEN
      intvariable:=0;
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • JedrzejTJedrzejT Member Posts: 267
    Thx, sometimes i forget about this .. especialy when write code not in system - like forum. I use more not needed code like BEGIN - END for one line case.. more readable for me..that's all.
  • kinekine Member Posts: 12,562
    JedrzejT wrote:
    Thx, sometimes i forget about this .. especialy when write code not in system - like forum. I use more not needed code like BEGIN - END for one line case.. more readable for me..that's all.

    Iam using the Begin-End too for one line conditions etc. (it is better for future). It is why I marked it as a tip, not mistake or bug... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.