(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Environment: MachineName, SystemDirectory, GetLogicalDrives, Version
Namespace MyApp.Info
Module Main
Sub Main()
Dim objHW As New MyApp.Info.Utilities
objHW.DisplayData()
End Sub
End Module
Public Class Utilities
"Run the application
Public Sub DisplayData()
Console.WriteLine(Environment.MachineName)
Console.WriteLine(Environment.SystemDirectory)
Console.WriteLine(Environment.GetLogicalDrives())
Console.WriteLine(Environment.Version.ToString())
End Sub
End Class
End Namespace
vbex
C:\WINDOWS\system32
System.String[]
2.0.50727.42
Environment.OSVersion
Imports System
Public Class Step3
Shared Sub Main()
System.Console.WriteLine(System.Environment.OSVersion.ToString())
End Sub
End Class
Microsoft Windows NT 5.1.2600 Service Pack 2
Environment.TickCount
Option Strict On
Public Module TimerFunction
Public Sub Main()
Dim starttime, endtime As Integer
starttime = Environment.TickCount
For ctr As Integer = 0 to 10000000
Next
endtime = Environment.TickCount
Console.WriteLine("Elapsed time is {0} milliseconds", endtime - starttime)
End Sub
End Module
Elapsed time is 16 milliseconds
Environment.UserName
Public Class LoopPerformance
Shared Sub Main()
Console.WriteLine(System.Environment.UserName)
End Sub
End Class
Joe
Get the command line arguments using the Environment class
Module Module1
Sub Main(ByVal cmdArgs() As String)
If Environment.GetCommandLineArgs.Length > 0 Then
For Each strArg As String In Environment.GetCommandLineArgs
"Process the arguments here.
Console.WriteLine(strArg)
Next strArg
End If
End Sub
End Module
main
Sort Command line arguments
Imports System.Collections
Module modMain
Sub Main()
Dim oArgs As New ArrayList(Environment.GetCommandLineArgs())
Dim I As Integer
With oArgs
.RemoveAt(0)
.Sort()
For I = 0 To .Count - 1
Console.WriteLine(.Item(I))
Next
End With
End Sub
End Module