Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,941 questions

51,879 answers

573 users

How to create an array of n random integers with a function and list on declaration in VB.NET

1 Answer

0 votes
Module Module1

    Sub Main()
        Dim arr() As Integer = CreateArray(13, 0, 100)

        For i As Integer = 0 To arr.Length - 1
            Console.Write("{0}  ", arr(i))
        Next
    End Sub

    Private Function CreateArray(total_elements As Integer,
                                 lower As Integer, upper As Integer) As Integer()
        Dim rnd As New Random()
        Dim list As New List(Of Integer)
        For i As Integer = 1 To total_elements
            list.Add(rnd.Next(lower, upper + 1))
        Next
        Return list.ToArray()
    End Function

End Module


' run:
' 
' 28  48  86  85  90  11  27  42  84  88  6  36  31

 



answered Apr 16, 2016 by avibootz

Related questions

1 answer 151 views
2 answers 175 views
2 answers 232 views
2 answers 218 views
1 answer 167 views
...