• how to build an array?

    Author
    Topic
    #354271

    How to build an array?

    I have the following lines in my code :

    If customer = 118 Then
    stock = stock – cartons
    ElseIf customer = 119
    stock = stock – cartons
    ElseIf customer = 120 Then ‘
    stock = stock – cartons
    ElseIf customer = 121 Then
    stock = stock – cartons
    ElseIf customer = 123 Then
    stock = stock – cartons

    Instead of these lines I want to build a simple code covering all the mentioned cusomers.
    If I build a line as:
    If customer 118 or 119 or 120 or 121 or 123 Then
    stock = stock – cartons
    I receive an error. I do not know why. Is there some other way of making this code, preferably with an array? I know it is ######ible but I cannot do it.

    Viewing 0 reply threads
    Author
    Replies
    • #520203

      Try:

          If (customer = 118) or (customer = 119) or (customer = 120) or _
            (customer = 121) or (customer = 123) then
              stock = stock - cartons
          End If
      
      • #520218

        Or try this:

        Select Case customer 
          Case 118, 119, 120, 121, 123
            stock = stock - cartons
        End Select

        This isn’t the situation that calls for an array.

    Viewing 0 reply threads
    Reply To: how to build an array?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: