1 Reply Latest reply on Mar 9, 2017 5:39 AM by Peter Brinkhuis

    set more values using "if true then"

    Lasse Nielsen

      Hello forum,

       

      Does anyone know if you can set two or more strings in on go?

       

      Currently my code looks like this

       

      If PPPP.Value = True Then Material = "PP-H 100, RAL 7032"

      If PPPE.Value = True Then Material = "PE-100, RAL 9005"

      If PPPP.Value = True Then MaterialCode = "PP"

      If PPPE.Value = True Then MaterialCode = "PE"

       

      But if would like to set Material and MaterialCode in one line of code, so both PP strings gets set if PPPP.value = true and both PE strings gets set if PPPE.value = true

       

      something like this

      If PPPP.Value = True Then Material = "PP-H 100, RAL 7032" (also) MaterialCode = "PP"

      If PPPE.Value = True Then Material = "PE-100, RAL 9005" (also) MaterialCode = "PE"

        • Re: set more values using "if true then"
          Peter Brinkhuis

          Well you don't need all those comparison, that's true. The single line If Then statement can be handy, but oftentimes you'll require multiple lines. In VBA it would be something like this:

           

          If PPPP.Value Then 'No need for the comparison with true, it can even cause unpredictable behavior

               Material = "PP-H 100, RAL 7032"

              MaterialCode = "PP"

          End If

           

          You can only set multiple variables to the same value in one line, like Test1 = Test2 = Test3 = True