here's my attempt at a solution:
Code:Imports System.Text.RegularExpressions Public Class Form1 Dim r As New Random Dim colors As New Dictionary(Of Integer, String) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load colors.Add(7, "Green") colors.Add(10, "Red") colors.Add(25, "Blue") colors.Add(58, "Yellow") ListBox1.Items.AddRange(Array.ConvertAll(colors.Values.ToArray, Function(s) s & " (0)")) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For y As Integer = 1 To 10000 Dim x As Integer = r.Next(1, 1451) Dim listIndex As Integer '/7 = 1450 '/10 = 1015 '/25 = 406 '/58 = 175 Select Case x Case Is > 1015 listIndex = r.Next(0, 4) Case Is > 406 listIndex = r.Next(1, 4) Case Is > 175 listIndex = r.Next(2, 4) Case Is > 0 listIndex = 3 End Select Dim rx As New Regex("(Red|Blue|Green|Yellow)\s\((\d+)\)") ListBox1.Items(listIndex) = Regex.Replace(ListBox1.Items(listIndex).ToString, rx.ToString, "$1 (" & (CInt(rx.Match(ListBox1.Items(listIndex).ToString).Groups(2).Value) + 1).ToString & ")") Next End Sub End Class




Reply With Quote