Attempting To Add Values Together. 追蹤

0
Avatar
Legacy Poster

Hello Team Seagull,

 

I am attempting to add values together however I am running into an issue when I attempt to cast the values to integer.

 

I have seen the topic below and it touches on my issue however I still have not been able to resolve my problem.

 

http://forums.seagullscientific.com/index.php?/topic/1841-add-function/?hl=%2Baddition+%2Bscri

 

I have 8 fields that will sometimes be populated with an integer value.

 

Quantity

 

1

2

3

4

5

6

7

Empty

 

I need to total the integers that do populate. and display them as the number of cartons.

 

Result = 28

 

The first field will always be populated with an integer.

 

The fact that sometimes the fields will be empty is causing a problem

 

The fields are being populated by a text file that is running through commander.

 

Any advice is appreciated.

 

Best Regards,

 

Brandon

 

I am currently populating those fields from a text file being output by our ERP system. There is no database connection.

1 意見

0
Avatar
Legacy Poster
評論操作 永久連結

Hello,

 

I don't know if you solved your issue yet, but I made a little script that loops through the eight fields and checks if it is empty. If the value is not empty it attempts to add the value of that field to the target field.
 

Dim Field
Value = 0
For count = 1 to 8
  Field = "Field_2_" + Cstr(count)
  If Not Trim(Format.NamedSubStrings(Field)) = "" Then
    Value = Value + Cint(Format.NamedSubStrings(Field).Value)
  End If
Next

Replace your code with this one under No. of Cartons:

登入寫評論。