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

Semrush - keyword research tool

Create your online store today with Shopify

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth

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

Disclosure: My content contains affiliate links.

43,227 questions

56,129 answers

573 users

How to initialize a stack with random numbers in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic

Class StackInit
    Private Shared Function InitStack(ByVal size As Integer, ByVal bound As Integer) As Stack(Of Integer)
        Dim stack As Stack(Of Integer) = New Stack(Of Integer)()
        Dim random As Random = New Random()

        For i As Integer = 0 To size - 1
            stack.Push(random.Next(1, bound + 1))
        Next

        Return stack
    End Function

    Public Shared Sub Main(ByVal args As String())
        Dim stack As Stack(Of Integer) = InitStack(15, 100)

        For Each num As Integer In stack
            Console.Write(num & " ")
        Next
    End Sub
End Class



' run:
'
' 52 77 47 4 14 92 43 22 33 63 74 50 98 14 100 
'

 



answered Oct 11, 2025 by avibootz
...