Advertisement
Guest User

Untitled

a guest
May 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.17 KB | None | 0 0
  1. Public Class Form1
  2.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  3.         Randomize()
  4.         Dim str As String = " "
  5.         Dim CaseVide As String = 15
  6.         Dim random As New Random()
  7.         Dim rnd As Integer
  8.         For x As Integer = 0 To 100
  9.             For j As Integer = 0 To 15
  10.  
  11.                 Dim i As Integer = j
  12.                 If (CaseVide = j) Then
  13.  
  14.                     If i > 3 And i < 12 Then
  15.                         rnd = random.Next(0, 4)
  16.                         If i Mod 4 = 3 Then
  17.                             Select Case rnd
  18.                                 Case 0
  19.                                     str += "" & CInt(i - 4)
  20.                                 Case 1
  21.                                     str += "" & CInt(i - 3)
  22.                                 Case 2
  23.                                     str += "" & CInt(i - 1)
  24.                                 Case Else
  25.                                     str += "" & CInt(i + 4)
  26.                             End Select
  27.                         ElseIf i Mod 4 = 0 Then
  28.                             Select Case rnd
  29.                                 Case 0
  30.                                     str += "" & CInt(i - 4)
  31.                                 Case 1
  32.                                     str += "" & CInt(i - 1)
  33.                                 Case 2
  34.                                     str += "" & CInt(i + 3)
  35.                                 Case Else
  36.                                     str += "" & CInt(i + 4)
  37.                             End Select
  38.                         Else
  39.                             Select Case rnd
  40.                                 Case 0
  41.                                     str += "" & CInt(i - 4)
  42.                                 Case 1
  43.                                     str += "" & CInt(i - 1)
  44.                                 Case 2
  45.                                     str += "" & CInt(i + 1)
  46.                                 Case Else
  47.                                     str += "" & CInt(i + 4)
  48.                             End Select
  49.                         End If
  50.                     ElseIf i <= 3 Then
  51.                         rnd = random.Next(0, 3)
  52.                         If i = 0 Then
  53.                             Select Case rnd
  54.                                 Case 0
  55.                                     str += "2"
  56.                                 Case 1
  57.                                     str += "4"
  58.                                 Case 2
  59.                                     str += "5"
  60.                             End Select
  61.                         ElseIf i = 3 Then
  62.                             Select Case rnd
  63.                                 Case 0
  64.                                     str += "1"
  65.                                 Case 1
  66.                                     str += "3"
  67.                                 Case 2
  68.                                     str += "8"
  69.                             End Select
  70.                         Else
  71.                             rnd = random.Next(0, 3)
  72.                             Select Case rnd
  73.                                 Case 0
  74.                                     str += "" & CInt(i - 1)
  75.                                 Case 1
  76.                                     str += "" & CInt(i + 1)
  77.                                 Case Else
  78.                                     str += "" & CInt(i + 4)
  79.                             End Select
  80.                         End If
  81.                     ElseIf i >= 12 Then
  82.                         rnd = random.Next(0, 3)
  83.                         If i = 12 Then
  84.                             Select Case rnd
  85.                                 Case 0
  86.                                     str += "9"
  87.                                 Case 1
  88.                                     str += "14"
  89.                                 Case 2
  90.                                     str += "16"
  91.                             End Select
  92.                         ElseIf i = 15 Then
  93.                             Select Case rnd
  94.                                 Case 0
  95.                                     str += "12"
  96.                                 Case 1
  97.                                     str += "13"
  98.                                 Case 2
  99.                                     str += "15"
  100.                             End Select
  101.                         Else
  102.                             rnd = random.Next(0, 3)
  103.                             Select Case rnd
  104.                                 Case 0
  105.                                     str += "" & CInt(i - 1)
  106.                                 Case 1
  107.                                     str += "" & CInt(i + 1)
  108.                                 Case Else
  109.                                     str += "" & CInt(i + 4)
  110.                             End Select
  111.                         End If
  112.                     End If
  113.                     str += " "
  114.                     CaseVide = CInt(str.ElementAt(str.Length - 2) & (str.ElementAt(str.Length - 1)))
  115.                 End If
  116.             Next j
  117.         Next x
  118.         MsgBox(str)
  119.     End Sub
  120.  
  121.     Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
  122.  
  123.     End Sub
  124. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement