title: Convert/Cast String (from a textbox) to IntPtr C#
body: <p>I have a textbox where I want to input (manually) a Handle (<a href="https://i.imgur.com/S1bCyPy.png" rel="noreferrer">http://i.imgur.com/S1bCyPy.png</a>)</p>
  
  <p>My problem: to get the value from the textbox I need to do this:</p>
  
  <pre><code>textBoxHandle.Text;
  </code></pre>
  
  <p>but when I initialize my Handle as IntPtr (handle), this doesn't work:</p>
  
  <pre><code>IntPtr h = new IntPtr(textBoxHandle.Text);
  </code></pre>
  
  <p>I have tried doing</p>
  
  <pre><code>(IntPtr) textBoxHandle.Text
  </code></pre>
  
  <p>And also many other options I've read around here like Marshal.StringToHGlobalAnsi Method but they don't work/ they change the content.</p>
  
  <p>My question: how do I get an IntPtr (handle) from the string (with a Handle format) that is in the textbox?</p>
  
  <p>EDIT: In the textbox I would write 0x00040C66 for instance.</p>
  
  <p>The final code should be:</p>
  
  <pre><code>IntPtr hWnd = new IntPtr(0x00040C66);
  </code></pre>
  
  <p>But changing the IntPtr for the value from the textbox.</p>
  
  <p>EDIT: My question was marked as duplicated (<a href="https://stackoverflow.com/questions/9175861/how-can-i-convert-an-unmanaged-intptr-type-to-a-c-sharp-string">How can I convert an unmanaged IntPtr type to a c# string?</a>) but it's not the same. It's not from IntPtr to String what I want. I need the opposite, from String to IntPtr.</p>