Advertisement
Guest User

vers2

a guest
Oct 23rd, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  2. Dim _NrOfTimes As String
  3. Dim _counter As Integer
  4. ListBox1.Items.Clear()
  5.  
  6. Try
  7. _NrOfTimes = CInt(Val(TextBox1.Text))
  8. '_NrOfTimes = Convert.ToInt32("_string_nr") ' converting string to number
  9. If _NrOfTimes = 0 Then 'wrong input - empty or string
  10. MsgBox("Please enter a number")
  11. Else : getList(_NrOfTimes)
  12. End If
  13. Catch ex As Exception
  14. MsgBox(ex.Message)
  15. End Try
  16.  
  17. End Sub
  18. Function getList(ByVal nr As Integer)
  19. Const a = 100, b = 200
  20. Dim _randomnum As Integer
  21. Dim _counter As Integer '??
  22.  
  23. Randomize()
  24.  
  25. For i = 1 To nr
  26. _randomnum = Int(Rnd() * (b - a + 1) + a)
  27. ListBox1.Items.Add(_randomnum & " - " & _counter)
  28. Next
  29.  
  30. Return True
  31. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement