Sign Validation

ravi_navisionravi_navision Member Posts: 102
Hi,

I have 2 fields. Qty1 and Qty2

When user enters on Qty2 field I want to validate Qty2 field sign should be
same as Qty1 field sign (Qty1 is non editable and always >0)


eg: Qty1 Qty2
+ve +ve


Thanks,
~~ravi

Comments

  • David_SingletonDavid_Singleton Member Posts: 5,479
    Hi,

    I have 2 fields. Qty1 and Qty2

    When user enters on Qty2 field I want to validate Qty2 field sign should be
    same as Qty1 field sign (Qty1 is non editable and always >0)


    eg: Qty1 Qty2
    +ve +ve


    Thanks,

    If Qty 1 is always > 0 then basically you want that Qty 2 is also positive, so

    Qty2 := Abs(qty2);

    Qty 1 is absolutely irrelevant.
    David Singleton
  • ravi_navisionravi_navision Member Posts: 102
    Qty can be Negative
    ~~ravi
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Qty1 is non editable and always >0
    Qty can be Negative

    How about you DECIDE what you want THEN we tell you how to code it.

    PS a number greater than 0 is positive :whistle:
    David Singleton
  • ravi_navisionravi_navision Member Posts: 102
    Thanks for your help David.

    I wrote one line of code to validate.
    IF ((Qty1 < 0) AND ("Qty2" >0)) OR ((Qty1 > 0) AND ("Qty2" <0)) THEN
    Error( )

    Just for my interest I want to know is there any other way of doing it.
    ~~ravi
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Thanks for your help David.

    I wrote one line of code to validate.
    IF ((Qty1 < 0) AND ("Qty2" >0)) OR ((Qty1 > 0) AND ("Qty2" <0)) THEN
    Error( )

    Just for my interest I want to know is there any other way of doing it.
    Qty1 is non editable and always >0



    But if Qty1 is always greater than 0 then Qty2 is also always greater than zero so ...

    IF "Qty2" < 0 THEN
    Error( );
    David Singleton
  • ravi_navisionravi_navision Member Posts: 102
    Sorry. Small change

    Qty1 is non editable and not equal to zero
    ~~ravi
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Sorry. Small change

    Qty1 is non editable and not equal to zero

    Big change actually, but now it makes sense:

    try :
    IF (Qty1 * "Qty2") < 0 THEN
      Error( )
    
    David Singleton
  • ravi_navisionravi_navision Member Posts: 102
    IF (Qty1 * "Qty2") < 0 THEN
    Error( )

    It works. Thank you David
    ~~ravi
Sign In or Register to comment.