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

51,819 answers

573 users

How to generate 20 digits random number in VB.NET

1 Answer

0 votes
Imports System
 
public class Generate20DigitsRandomNumber_VB_NET
    public Shared Function Generate20DigitsRandomNumber() As Decimal
        Dim rand As Random = New Random()
        Dim s As String = String.Empty
 
        For i As Integer = 0 To 20 - 1
            s = String.Concat(s, rand.Next(1, 9).ToString())
        Next
 
        Dim dec As Decimal
 
        If Not Decimal.TryParse(s, dec) Then
            Console.WriteLine("Error: Decimal.TryParse(s, out dec)")
            Return -1
        End If
 
        Return dec
    End Function
 
    public Shared Sub Main()
        Console.WriteLine(Generate20DigitsRandomNumber())
    End Sub
End Class
 
  
  
' run:
' 
' 74523152177568121885
'

 



answered Nov 9, 2024 by avibootz
edited Jun 26, 2025 by avibootz
...