# Field Calculator syntax vb calculating slope percentage

666
5
02-18-2014 07:24 AM New Contributor
I am attempting to calculate the slope of sewer lines. I am apparently missing some fundamentals of vb to get the syntax correct. I have fields:
From_Invert
To_Invert
Length (calculated)

The mathematical equation (rise/run) should be something like this:

(([From_Invert] -[To_Invert])/[Length])*100
I can't get it to fly in the field calculator. Any help would be greatly appreciated.
Regards,
Dana
Tags (2)
5 Replies Frequent Contributor III
I just use the simple   Slope= RISE/RUN

and multiply that times 100 to get a %

RISE = change in elevation
RUN = Distance

So what your doing looks right.

What is the attribute you are trying to do it in?  It should be a double precision.  If it is a long or short integer or may not work.

I am attempting to calculate the slope of sewer lines. I am apparently missing some fundamentals of vb to get the syntax correct. I have fields:
From_Invert
To_Invert
Length (calculated)

The mathematical equation (rise/run) should be something like this:

(([From_Invert] -[To_Invert])/[Length])*100
I can't get it to fly in the field calculator. Any help would be greatly appreciated.
Regards,
Dana New Contributor
Robert,
Thank you for your prompt reply. All of the fields are doubles.

I have attached a screen shot of the error I get when running the field calculator with the exact formula from my original post.

Thanks again,
Dana Frequent Contributor III

Are they also a double or integer?  As well as your length field

Have you verified that all the Invert and length fields have values.

Try this

((abs([From_Invert] -[To_Invert]))/[Length])*100

Select just one feature in your table and run it on just that.

For length are you using the shape length or a calculated length.

If you still get the error run it again but instead of using shapelenght put in some number like 150

Robert,
Thank you for your prompt reply. All of the fields are doubles.

I have attached a screen shot of the error I get when running the field calculator with the exact formula from my original post.

Thanks again,
Dana New Contributor
Robert,
I ran it on one and it worked. I found a sneaky null value in the elevation fields! Thank you for all of your help talking me through this.Probably the easiest problem you've helped with today :)
Thanks again!!!
Dana Frequent Contributor III
Null value would do it.  Glad it worked out for you.

Robert,
I ran it on one and it worked. I found a sneaky null value in the elevation fields! Thank you for all of your help talking me through this.Probably the easiest problem you've helped with today :)
Thanks again!!!
Dana 