Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDetermine what version of Access is installed by using automation in Visual Basic 2005
DescriptionThis example shows how to determine what version of Access is installed by using automation in Visual Basic 2005.
KeywordsAccess, Access version, Microsoft Access, Registry, automation, VB.NET, Visual Basic 2005
CategoriesOffice, Software Engineering, Tips and Tricks, VB.NET
 
Function GetAccessVersionName creates an Access.Application object and looks at its Version property. The other routines use the result returned by this one to get Access's number and "nice" name.
 
' Determine the Access version by creating an
' Access.Application object and looking at
' its Version property.
Public Function GetAccessVersionName() As String
    Dim obj As Object = CreateObject("Access.Application")
    Dim result As String = "Access.Application." & _
        obj.Version
    obj.Quit()
    Return result
End Function

' Get the Access version number from the name.
Public Function GetAccessVersionNumber() As Integer
    Dim txt As String = GetAccessVersionName()
    Dim pos2 As Integer = txt.LastIndexOf(".")
    Dim pos1 As Integer = txt.LastIndexOf(".", pos2 - 1)
    txt = txt.Substring(pos1 + 1, pos2 - pos1 - 1)
    Return CInt(txt)
End Function

' Get the nice style of the Access version name.
Public Function GetAccessVersionNiceName() As String
    Select Case GetAccessVersionNumber()
        Case 8
            Return "Access 97"
        Case 9
            Return "Access 2000"
        Case 10
            Return "Access 2002" ' XP
        Case 11
            Return "Access 2003"
        Case 12
            Return "Access 2007"
        Case Else
            Return "unknown"
    End Select
End Function
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated