The following piece of code blurs a picture box but the compiler wont let me use a variable for the picture width or height, it only wants a constant. Can anyone tell me Why i cant use a variable (intUpperBoundY) in the DIM PIXELS line (1st line of code)? This value may change depending on the size of the picture I am blurring and so cant use a constant. Thanks for any pointers

VB Code:
  1. Private Sub Blur(intUpperBoundX, intUpperBoundY)
  2.     Dim Pixels(1 To intUpperBoundX, 1 To intUpperBoundY) As Long
  3.     Dim x, y As Integer
  4.     Dim bytRed, bytGreen, bytBlue As Byte
  5.    
  6.     For x = 1 To intUpperBoundX
  7.         For y = 1 To intUpperBoundY
  8.             Pixels(x, y) = Picture1.Point(x, y)
  9.         Next y
  10.     Next x
  11.    
  12.     For x = 1 To intUpperBoundX - 1
  13.         For y = 1 To intUpperBoundY
  14.             bytRed = Abs((Pixels(x + 1, y) And &HFF) + (Pixels(x, y) And &HFF)) / 2
  15.             bytGreen = Abs(((Pixels(x + 1, y) And &HFF00) / &H100) Mod &H100 + ((Pixels(x, y) And &HFF00) / &H100) Mod &H100) / 2
  16.             bytBlue = Abs(((Pixels(x + 1, y) And &HFF0000) / &H10000) Mod &H100 + ((Pixels(x, y) And &HFF0000) / &H10000) Mod &H100) / 2
  17.             Pixels(x, y) = RGB(bytRed, bytGreen, bytBlue)
  18.          Next y
  19.     Next x
  20.    
  21.    
  22.     For x = 1 To intUpperBoundX
  23.         For y = 1 To intUpperBoundY
  24.             Picture2.PSet (x, y), Pixels(x, y)
  25.         Next y
  26.     Next x
  27.    
  28. End Sub


Is it possible to create a constant on the fly based on a variable?