How to show version number on a .NET windows form app

Posted on 2006-05-29
Last Modified: 2010-04-23
I know that the APP object that was available in VB6 is not supported in .NET but the assembly has a version attribute consiting of 4 parts and that the build number is automatically incremented with each build. I want to display all 4 numbers on a form caption (now called text) in a VB.NET Windows forms application. How do I access that info in the VB code or set the form's text property to that number?
Question by:tomkovic
    LVL 62

    Accepted Solution

           Dim verMajor As String
            Dim verMinor As String
            Dim verBuild As String
            Dim verPrivate As String

            With System.Diagnostics.FileVersionInfo.GetVersionInfo( _
                verMajor = .FileMajorPart.ToString()
                verMinor = .FileMinorPart.ToString()
                verBuild = .FileBuildPart.ToString()
                verPrivate = .FilePrivatePart.ToString()
            End With

            Me.Text = "Version = " & verMajor & "." & verMinor & "." & _
                verBuild & "." & verPrivate


    Author Comment

    Great Answer. Can you point me to a reference that explains this so that I may better understand this?

    I will just cut and paste the code for now but I want to understand the process better.

    Thanks for the help.
    LVL 62

    Expert Comment

    by:Fernando Soto
    Information about the file version number can be gotten from the documentation at MSDN web site at:

    and the GetVersionInfo method will retrieve the parts of the version number for the specific file, in this case the executing assembly and is gotten by using the Reflection class.

    and using the GetExecutingAssembly method.

    LVL 5

    Expert Comment

    If you are building your own software, you can set the version number in the AssembyInfo.vb file.

    <Assembly: AssemblyVersion("1.00.00")>
    <Assembly: AssemblyVersion("1.05.01")>
    <Assembly: AssemblyVersion("5.00.00")>

    you can reference your version number anytime in your code by using "Application.ProductVersion".  However, this is display ALL information including the

    Fernando's example gives you some greater control over the display.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now