If you have already booted up your operating system, then the screen may become black if your computer has power saving mode enabled to minimize energy use.
The reason for your screen turning black may be :
A screensaver
A computer crash
Your video card is overheated
Your monitor-CPU wire is malfunctioning.
Your screen turns black after you turn on your computer because you have not turned on your monitor or you graphics drivers have failed and it cant render the desktop.
Your screen turns black is because your computer has turned off. The power is no longer going to the computer that allowed the screen to stay visible. Dont worry just hit the power button and everything should turn back on with no problem. If there is a problem check to see if it is pluged in all the way.