From a custom module. How can I get the typed value from a textfield and put it in a variable?
All entered values are in the $form_state array on submit. It is up to you to process that data and store it in a variable.

For example...

function mymodule_myform_submit($form, $form_state) {
  $text = $form_state['values']['myfield'];
  variable_set('mymodule_var', $text);
}


Then wherever else in the site you want to show it...

$myvar = variable_get('mymodule_var', '');


Of course, be sure to validate your input in the validate handler and anything else you want to process and save. This is pretty much the most basic approach in 7 to collect and store variables (especially not knowing the rest of your setup).