VynxDev

Shuffle Image Array Help

Jan 25th, 2021
2,241
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub shuffleArray(arr As Image())
  2.         Dim n As Integer = arr.Length
  3.         Dim ran As New Random
  4.  
  5.         For i = 0 To arr.Length - 1
  6.             swap(arr, i, i + ran.Next(n - i))
  7.         Next
  8.  
  9.     End Sub
  10.     Public Sub swap(array As Image(), a As Integer, b As Integer)
  11.         Dim temp As Image = array(a)
  12.         array(a) = array(b)
  13.         array(b) = temp
  14.     End Sub
  15.  
  16.     Public Sub loadImages(images As Image())
  17.         shuffleArray(images)
  18.         For Each pb As PictureBox In cb 'Loops through all pictureboxes and fills them with an image.
  19.            pb.BackgroundImage = images(i)
  20.             pb.BackgroundImageLayout = BackgroundImageLayout.Stretch
  21.             i += 1
  22.         Next
  23.  
  24.     End Sub
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×