To find the value of \( x \) when two angles are complementary, we start by remembering that complementary angles add up to \( 90^\circ \).
Given:
- The first angle measures \( 40^\circ \).
- The second angle measures \( (8x + 2)^\circ \).
We can set up the equation:
\[ 40 + (8x + 2) = 90 \]
Now, simplify and solve for \( x \):
- Combine like terms:
\[ 40 + 2 + 8x = 90 \] \[ 42 + 8x = 90 \]
- Subtract 42 from both sides:
\[ 8x = 90 - 42 \] \[ 8x = 48 \]
- Divide by 8:
\[ x = \frac{48}{8} = 6 \]
Therefore, the value of \( x \) is:
\[ \boxed{6} \]