Obviously as above this hugely depends on the language, but you can usually get the text in the textbox as a string and subsequently find out the length of the text.
So in Java for instance it'd be something like:
Code:
int remaining = 1000-textBox.getText().length();
countTextBox.setText(Integer.toString(remaining));
Translate to language of your choice!