Guest
Private paste!

Visual Basic Example 2

By: a guest | Apr 12th, 2010 | Syntax: VB.NET | Size: 0.82 KB | Hits: 143 | Expires: Never
Copy text to clipboard
  1. Module Module1
  2.  
  3.     Sub Main(ByVal sArgs() As String)
  4.         'Note the declaration of the Sub Main line
  5.         'It has the sArgs parameter.  This parameter is handled by
  6.         'the system, and contains any command line arguments.
  7.  
  8.         If sArgs.Length = 0 Then                'If there are no arguments
  9.             Console.WriteLine("Hello World! <-no arguments passed->") 'Just output Hello World
  10.         Else                                    'We have some arguments        
  11.             Dim i As Integer = 0
  12.  
  13.             While i < sArgs.Length             'So with each argument
  14.                 Console.WriteLine("Hello " & sArgs(i) & "!") 'Print out each item
  15.                 i = i + 1                       'Increment to the next argument
  16.             End While
  17.  
  18.         End If
  19.  
  20.         Console.ReadLine()
  21.  
  22.     End Sub
  23.  
  24. End Module