Share via


Visual Basic Concepts

SysInfo Scenario 1: Detect the Current Operating System and Version

You can detect and display the current operating system platform, version, and build number by using a CommandButton control and the OSPlatform, OSVersion, and OSBuild properties. You can test this by adding a CommandButton control to a form and then adding the following code the cmdDetectOS_Click event procedure:

Private Sub cmdDetectOS_Click()
   Dim MsgEnd As String
   Select Case sysDetectOS.OSPlatform
      Case 0
         MsgEnd = "Unidentified"
      Case 1
         MsgEnd = "Windows 95, ver. "& _
CStr(sysDetectOS.OSVersion) & "(" & _
CStr(sysDetectOS.OSBuild) & ")"
      Case 2
         MsgEnd = "Windows NT, ver. " & _
CStr(sysDetectOS.OSVersion) & "(" & _
CStr(sysDetectOS.OSBuild) & ")"
   End Select
   MsgBox "System: " & MsgEnd
End Sub

For More Information   See OSPlatform, OSVersion, and OSBuild properties.