# Metode for applying zero to a value

Hi! I am trying to make a method for applying zeroes to a decimal value. I want it to be in whole numbers and I therefor need to convert the Balance to int. When I do this I get an Error message. I also need to delete blank space before using strlen(), or is the blank space deleted by converting it to int? What is wrong here? Maybe there already is a method to do this? Balance:=decimal; number:=int; answer:=text; Balance:=customer.“Net Change (LCY)”; EVALUATE(int,Balance); //since balance is an Decimal and I want Int number:=STRLEN(FORMAT(int)); CASE number OF 3: Answer:= Text000+FORMAT(int); ‘’ ‘’ EXIT(Answer); END; TiA

Maybe this will do it: Balance:=decimal; BalanceInt:=text number:=int; answer:=text; Balance:=customer.“Net Change (LCY)”; BalanceInt := FORMAT(Balance,0,’<Precision,0:0><Standard Format,0>’); number:=STRLEN(BalanceInt); CASE number OF 3: Answer:= Text000+BalanceInt; ‘’ ‘’ EXIT(Answer); END;

In Navision it is not necessary to explicitly convert decimals to integer before assigning it, you just need to make sure that the decimal does not contain decimal places. ` number := ROUND(Balance,0); CASE number OF 0..9: // Do something 10..99: // Do something 100..999: //Do something 1000..9999: //Do something END; ` But I would like to ask what you have in Text000 as thee might be a shorter way to achieve what you want

Thanx to both! Only the first thing worked. The round() gave a out of range error. The text is just diffrent amount of zeroes to add in front of the value. Is there a function to remove blank space in a number?

The easiest way for what you want to do is: ` Answer := FORMAT(Balance,0,'<INTEGER,10><Filler Character,0>'); ` just replace the 10 in the <INTEGER,10> with the number of digits you want to have for the answer. Navision can be very easy [;)]

Thanx Thomas, I’ll try that… I’m new at this… Since U say navision can be very easy… I’m working on another topic right now. I’m tearing my hair off… Maybe U can tell me how to get the record from an activated line in a journal? Can you use datacaptionfield in any way? I’m using the record to do a distribution… I am thinking about something like this… but I dont always find the right record… Rec.FIND(’-’); batch:=Rec.“Journal Batch Name”; template:=Rec.“Journal Template Name”; linjenr:=Rec.“Line No.”; Rec.SETRANGE(“Journal Template Name”,template); Rec.SETRANGE(“Journal Batch Name”,batch); Rec.SETRANGE(“Line No.”,linjenr); Do you have a suggestion??It would help me a lot!

The REC variable already contains the active line in a list form. So you can use it right away. So if you would create a psh button that only contains the following code in the OnPush Trigger: ` MESSAGE('Active Line No. :',"Line No."); ` you get the active line no. displayed. By the way, mostly it helps much more if you ask based on what you are trying to achieve. [;)]

You are right Thomas! Navision can be very easy…I’m the one who is complicated… Thanx! again…