What the hell is standard deviation anyway?

Well I wrote a prog to calculate the mean and standard devation of a set of numbers. The mean part was easy enough but I'm having probs with the standard deviation. Here is the code I'm using:
VB Code:
  1. Dim X As Long
  2. Dim SumX1 As Single
  3. Dim SumX2 As Single
  4. Dim NumValues As Integer
  5.  
  6. 'Seperate Numbers'
  7. Array1 = Split(txtNumbers.Text, ",")
  8.    
  9. Total = 0
  10. For X = 0 To UBound(Array1)
  11.     Total = Total + Array1(X)
  12. Next X
  13.  
  14. SumX1 = SumX1 + Total
  15. SumX2 = SumX2 + Total ^ 2
  16. NumValues = UBound(Array1) + 1
  17.  
  18. 'Calculate and Display Mean
  19. Mean = SumX1 / NumValues
  20. lblMean.Caption = Mean
  21.  
  22. 'Calculate and Display Standard Deviation
  23. Stdev = Sqr((NumValues * SumX2 - SumX1 ^ 2) / (NumValues * (NumValues - 1)))
  24.  
  25. lblDeviation.Caption = Stdev

I'm not getting the right answer for the standard deviation. So maybe one of you brainy guys could tell me where I've gone wrong.