If (and this is a big if) you are considering a symmetric $\pm1$ random walk or a driftless Brownian motion starting from $x=40$ and you are wondering about the probability $u(x)$ that it hits $x_1=100$ before hitting $x_0=-100$, then indeed the answer is
Briefly, an elementary method in the random walk case is to compute $u(x)$ for every integer starting point $x$ between $x_0$ and $x_1$. For every such $x$, one has $50\%$ chances that the first step is to $x+1$ and $50\%$ chances that the first step is to $x-1$, and from there, one looks for the probability $u(x\pm1)$ to hit $x_1$ before $x_0$. Hence,
This means that $x\mapsto u(x)$ is a straight line on the integer interval $[x_0,x_1]$. Obviously, $u(x_0)=0$ and $u(x_1)=1$ hence $u(x)$ is as written above.
A slightly more advanced method is to consider the position $X_n$ of the random walk at time $n\wedge\tau_0\wedge\tau_1$ where $\tau_0$ is the first hitting time of $x_0$ and $\tau_1$ is the first hitting time of $x_1$. This means that the random walk performs equiprobable independent $\pm1$ steps and that one stops it as soon as it hits $x_0$ or $x_1$. Then $(X_n)$ is a bounded martingale hence its expectation does not depend on $n$. Now $X_0=x$, $X_n\to x_1$ on $S=[\tau_1<\tau_0]$, $X_n\to x_0$ on $[\tau_0<\tau_1]=S^c$, and one gets $$
Since $P(S)+P(S^c)=1$, this yields the result.
In the Brownian motion case, one can still use the idea of the second method, replacing finite differences by a differential operator: one gets that $u(x_0)=0$, $u(x_1)=1$ and $u''(x)=0$ for every real number $x$ in the interval $(x_0,x_1)$. This means that $u$ is affine in this case as well hence $u(x)$ is given by our first displayed formula, where now the argument $x$ is a real number.