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

51,796 answers

573 users

How to use optional argument in sub for a default value parameter in VB.NET

2 Answers

0 votes
Module Module1

    Sub Print(ByVal Optional s As String = "VB.NET")
        Console.WriteLine(s)
    End Sub

    Sub Main()

        Print()
        Print("C++")
        Print("Java")

    End Sub

End Module


' run:
' 
' VB.NET
' C++
' Java

 



answered Oct 21, 2018 by avibootz
0 votes
Module Module1

    Sub Print(ByVal Optional s As String = "VB.NET",
              ByVal Optional n As Integer = 99)
        Console.WriteLine($"{s} {n}")
    End Sub

    Sub Main()
        Print()
        Print("Java")
        Print("C#", 2)
        Print(s:="Python")
        Print("C++", n:=12)
        Print(n:=9834, s:="PHP")
        Print(n:=100)
    End Sub

End Module


' run:
' 
' VB.NET 99
' Java 99
' C# 2
' Python 99
' C++12
' PHP 9834
' VB.NET 100

 



answered Oct 21, 2018 by avibootz

Related questions

...