Data Conversion from Text to Decimal!!!

HanenHanen Member Posts: 281
Hello,

I have a problem to convert text to decimal, help!!!

lQty:= lCdu_ADO.ReadField_TEXT(pADORecSet,'ValeurParametre');
lcontractRec.SETRANGE(lcontractRec.NAboPere,lTxt_Temp);
IF lcontractRec.FINDFIRST THEN BEGIN
lCustomerRec.SETRANGE(lCustomerRec."No.",lcontractRec."Customer No.");
    IF lCustomerRec.FINDFIRST = TRUE THEN BEGIN

EVALUATE(lCustomerRec."Taux Récurrent",CONVERTSTR(lQty,'()','  '));
lCustomerRec.VALIDATE(lCustomerRec."Taux Récurrent",lQty);
lCustomerRec.MODIFY;

   END;//FIN IF CUSTOMER

END;

Regards

Hanen TALBI

Comments

  • MatthiasKönigMatthiasKönig Member Posts: 14
    Hi,

    sry I dont read your code but the text to decimal problem you can solve like this:
    txt = text
    dec = decimal
    SalesLine.RESET;
    SalesLine.SETFILTER(Amount, txt);
    
    txt := SalesLine.GETFILTER(Amount);
    
    EVALUATE(dec, txt)
    

    The sales line table is only one possibility! important is the field on which you filter! it must be an decimal field.
  • kinekine Member Posts: 12,562
    May be that the decimal have different format than NAV is using? WHat is exact error?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,304
    It's no surprise that you can't make any sense of it, that code looks like a big fat mess. You have to do something about your code indentation and make it easier to read. You also have to start thinking about why you would use FINDFIRST, as opposed to FINDSET or even GET.
  • kinekine Member Posts: 12,562
    I do not understand this code:
    EVALUATE(lCustomerRec."Taux Récurrent",CONVERTSTR(lQty,'()','  '));
    lCustomerRec.VALIDATE(lCustomerRec."Taux Récurrent",lQty);
    

    If lQty is text (you are using CONVERTSTR to it), why you are trying to VALIDATE the string into the decimal field? If it is decimal, why you are using EVALUATE and CONVERTSTR on it? You need to rething your code, make it clear for yourself. It seems that you have get lost in your own code (if it is your code)... :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.