This code causes an error when you type in the password. Anyone know why?

VB Code:
  1. Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
  2.  
  3. Option Explicit
  4. Option Base 1 'This is so the arrays are 1-based
  5.  
  6. Private Const SRCCOPY = &HCC0020
  7.  
  8. 'Declare the API functions (DrawPixelV, GetPixel, GetTickCount and
  9. 'BitBlt)
  10.  
  11. Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, _
  12. ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
  13.  
  14. Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
  15. ByVal X As Long, ByVal Y As Long) As Long
  16.  
  17. Private Declare Function GetTickCount Lib "kernel32" () As Long
  18.  
  19. Private Declare Function BitBlt Lib "gdi32" ( _
  20. ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, _
  21. ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
  22. ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  23.  
  24.  
  25. 'This is the type that defines one of our particles...
  26. Private Type tParticle
  27.     'Position
  28.     X As Single
  29.     Y As Single
  30.    
  31.     'Horizontal/vertical speed
  32.     SpeedX As Single
  33.     SpeedY As Single
  34.    
  35.     'State (0 = Moving down; 1 = Fading away [touched the ground])
  36.     State As Byte
  37.    
  38.     'Colors
  39.     ColorR As Byte
  40.     ColorG As Byte
  41.     ColorB As Byte
  42. End Type
  43.  
  44.  
  45. 'This array holds all of our particles
  46. Dim Particles() As tParticle
  47.  
  48. 'The number of particles in the array (this is so we don't have to
  49. 'use UBound all the time)
  50. Dim NumParticles As Long
  51.  
  52. 'The number of active particles. This is used so that not all the
  53. 'particles are active at first. The number starts at 0 and is
  54. 'increased each frame. Only these particles are moved and drawn
  55. '(the ones which have an index <= this number)
  56. 'NOTE: It's a Single so that we can increase it by a number smaller
  57. 'than 1, eg.: if you increase it 0.1 every frame, you'll get one
  58. 'more active particle every 10 frames :)
  59. Dim ActiveParticles As Single
  60.  
  61. 'This is True while the loop is running (it's for the "game engine",
  62. 'you should have something similar in your game loop so it's not
  63. 'important for the particles system itself)
  64. Dim Running As Boolean
  65.  
  66. 'This is used to slow down the FPS (so it doesn't run too fast)
  67. Dim LastTick As Long
  68.  
  69. 'A temporary loop counter
  70. Dim i As Long
  71.  
  72. 'The wind speed
  73. Dim WindSpeed As Single
  74.  
  75. 'The speed of the rain
  76. Private Const SpeedMultiplier As Single = 6
  77. Private Sub Form_Load()
  78.     'Load the background image
  79. Me.Move 0, 0, Screen.Width, Screen.Height
  80. picBackgroundImage.Move 0, 0, Me.Width, Me.Height
  81. picBack.Move 0, 0, Me.Width, Me.Height
  82.  
  83. picBackgroundImage.Picture = LoadPicture(App.Path & "\background.bmp")
  84.  
  85.     'Generate new random numbers
  86.     Randomize Timer
  87.    
  88.     SystemParametersInfo 97, True, CStr(0), 0
  89.    
  90.     'First we'll have to initialize all the particles...
  91.    
  92.     'Resize the array
  93.     NumParticles = 200000
  94.     ReDim Particles(NumParticles)
  95.    
  96.     'Loop trough all of the particles...
  97.     For i = 1 To NumParticles
  98.         With Particles(i)
  99.        
  100.         'This will center this particle on the screen
  101.         .X = Rnd * picBack.Width
  102.         .Y = -2
  103.        
  104.         'Set the horizontal/vertical speed
  105.         .SpeedY = 1 + Rnd 'A number between 1 and 2
  106.        
  107.         'Set the color to a random shade of a very bright and pale
  108.         'blue... Part of the color is multiplied by the vertical
  109.         'speed, so the greater the vertical speed is, the brighter
  110.         'the particle is :)
  111.                 .ColorB = 98 + 40 * .SpeedY
  112.                 .ColorG = 72 + 40 * .SpeedY
  113.                 .ColorR = 31 + 40 * .SpeedY
  114.        
  115.         'Now, multiply the speed by the speed multiplier to get
  116.         'the real speed (for the values I used for the colors, the
  117.         'speed MUST NOT be greater than 2, so we can't multiply it
  118.         'earlier)
  119.         .SpeedY = .SpeedY * SpeedMultiplier
  120.        
  121.         End With
  122.     Next i
  123.    
  124.    
  125.     'Make sure everything's initialized
  126.     Me.Show
  127.     DoEvents
  128.    
  129.     'This is the main loop!
  130.     Running = True
  131.     Do While Running
  132.         'Slow down the FPS...
  133.         Do
  134.             DoEvents
  135.         Loop Until GetTickCount() >= LastTick + 30
  136.         LastTick = GetTickCount()
  137.        
  138.            
  139.  
  140.         'Draw the background image into the backbuffer
  141.         BitBlt picBack.hdc, 0, 0, picBack.Width, picBack.Height, _
  142.           picBackgroundImage.hdc, 0, 0, SRCCOPY
  143.        
  144.         'Run the particles system!
  145.         RunParticles
  146.        
  147.     Loop
  148. End Sub
  149.  
  150. Private Sub Form_Unload(Cancel As Integer)
  151.     'Terminate the loop and exit
  152.     Running = False
  153.     DoEvents
  154.     End
  155. End Sub
  156.  
  157. Private Sub picBack_Click()
  158. Dim RealPassword, Password As String
  159. RealPassword = GetSetting("ScreenSaver", "settings", "password", "")
  160. Password = InputBox("Enter Password:", "Password")
  161. If Password = RealPassword Then
  162. SystemParametersInfo 97, False, CStr(0), 0
  163. End
  164. End If
  165. End Sub
  166.  
  167. Private Sub picBackgroundImage_Paint()
  168. picBackgroundImage.Picture = LoadPicture(App.Path & "\collybia.bmp")
  169. End Sub
  170.  
  171. Private Sub RunParticles()
  172.     Dim tR As Byte, tG As Byte, tB As Byte, tempcheck As Byte
  173.     Dim j As Long
  174.    
  175.     'Increase the number of active particles...
  176.     If ActiveParticles < NumParticles Then
  177.         ActiveParticles = ActiveParticles + Rnd
  178.         If ActiveParticles > NumParticles Then ActiveParticles = NumParticles
  179.     End If
  180.    
  181.     'Loop trough all of the particles...
  182.     For i = 1 To ActiveParticles
  183.         With Particles(i)
  184.        
  185.         'Move this particle according to its speed
  186.         .X = .X + WindSpeed
  187.         .Y = .Y + .SpeedY
  188.        
  189.         'Check if it has reached the left/right edges of the screen,
  190.         'in that case move it to the other edge...
  191.         If .X < 0 Then .X = .X + picBack.Width
  192.         If .X > picBack.Width Then .X = .X - picBack.Width
  193.        
  194.         'Check if it has reached the bottom...
  195.         If .Y >= picBack.Height Then
  196.             'Move it back to the top again
  197.             .X = Rnd * picBack.Width
  198.             .Y = -2
  199.         End If
  200.        
  201.         If .State = 0 Then
  202.             'If it's falling...
  203.            
  204.             'This will make the particles randomly touch the
  205.             'ground sometimes (we set the state to 1 so that
  206.             'from now on they'll fade)
  207.             If Rnd < 0.002 Then .State = 1
  208.         Else
  209.             'If it's fading...
  210.            
  211.             'Slowly fade the particle to black...
  212.             .ColorR = .ColorR - 1
  213.             .ColorG = .ColorG - 1
  214.             .ColorB = .ColorB - 1
  215.            
  216.             'Check if it stopped fading (it's almost black)...
  217.             If .ColorR < 32 Then
  218.                 'Move it back to the top again
  219.                 .X = Rnd * picBack.Width
  220.                 .Y = -2
  221.                
  222.                 'Set the state so it doesn't fade anymore
  223.                 .State = 0
  224.                
  225.                 'Set the speed again (between 1 and 2)
  226.                 .SpeedY = 1 + Rnd
  227.                
  228.                 'Set the color again...
  229.                
  230.                 .ColorB = 98 + 40 * .SpeedY
  231.                 .ColorG = 72 + 40 * .SpeedY
  232.                 .ColorR = 31 + 40 * .SpeedY
  233.                
  234.                 'Multiply it by the speed multiplier
  235.                 .SpeedY = .SpeedY * SpeedMultiplier
  236.             End If
  237.         End If
  238.        
  239.         'Draw it as a vertical line, according to the speed
  240.         '(the greater the speed, the longer the line is)
  241.         For j = 0 To .SpeedY \ 4
  242.             DrawPixel .X, .Y + j, .ColorR, .ColorG, .ColorB
  243.         Next j
  244.        
  245.         End With
  246.     Next i
  247. End Sub
  248.  
  249. 'This function draws a pixel using a special effect
  250. Private Sub DrawPixel(ByVal X As Long, ByVal Y As Long, _
  251.   ByVal R1 As Byte, ByVal G1 As Byte, ByVal B1 As Byte)
  252.     Dim TempColor As Long
  253.     Dim R2 As Long, G2 As Long, B2 As Long
  254.    
  255.     'Get the color of the original pixel
  256.     TempColor = GetPixel(picBack.hdc, X, Y)
  257.    
  258.     'Extract each one of the RGB values of the original pixel
  259.     '(don't waste your time trying to understand it :)  )
  260.     R2 = TempColor And 255
  261.     G2 = (TempColor And 65535) \ 256
  262.     B2 = (TempColor And 16777215) \ 65536
  263.    
  264.     'Add the original RGB values to the particle's RGB values
  265.     R2 = R2 + R1
  266.     G2 = G2 + G1
  267.     B2 = B2 + B1
  268.    
  269.     'Check if they're not above 255
  270.     If R2 > 255 Then R2 = 255
  271.     If G2 > 255 Then G2 = 255
  272.     If B2 > 255 Then B2 = 255
  273.    
  274.     'Draw the pixel
  275.     SetPixelV picBack.hdc, X, Y, RGB(R2, G2, B2)
  276. End Sub

Code written by Jotaf98 works (the actual system), but my altering causes it to have the 'performed illegal opertion' thing. All the pic boxes exist.