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,885 questions

51,811 answers

573 users

How to generate random numbers between N1 and N2 in VB.NET

3 Answers

0 votes
Module Module1

    Sub Main()

        Dim r As Random = New Random

        Console.WriteLine(r.Next(1, 10))
        Console.WriteLine(r.Next(20, 40))

    End Sub

End Module

' run:
' 
' 5
' 20

 



answered Sep 22, 2018 by avibootz
0 votes
Module Module1

    Sub Main()

        Dim r As Random = New Random

        For i As Integer = 1 To 25
            Console.WriteLine(r.Next(10, 14))
        Next

    End Sub

End Module

' run:
' 
' 10
' 12
' 10
' 11
' 12
' 12
' 13
' 13
' 10
' 11
' 12
' 11
' 10
' 13
' 10
' 12
' 11
' 11
' 13
' 12
' 13
' 13
' 10
' 13
' 10

 



answered Sep 22, 2018 by avibootz
0 votes
Imports System
 
Public Class Test
    Public Shared Function get_random_number(min As Integer, max As Integer) As Integer
        Dim rnd As System.Random = New System.Random()
        Return rnd.Next(min, max)
    End Function
     
    Public Shared Sub Main()
        For i As Integer = 0 To 10
            Console.WriteLine(get_random_number(17, 122))
        Next
    End Sub
End Class
 
 
 
' run:
'
' 112
' 121
' 88
' 81
' 98
' 22
' 18
' 76
' 90
' 101
' 89

 



answered Nov 30, 2019 by avibootz

Related questions

2 answers 235 views
1 answer 155 views
1 answer 144 views
1 answer 139 views
1 answer 109 views
...