Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Load/Application Version

Status
Not open for further replies.

RoguePoet01

Programmer
Joined
Oct 1, 2003
Messages
302
Location
US
Hi,

In VB6, during the Form Load event, I used to use:

form1.Caption = " Program Name, " & App.Major & "." & App.Minor & "." & App.Revision

Which would give me a form caption of "Program Name, 1.0.0"

I can't find quite the same thing in VB.net.

Any suggestions where to look?

Thanks.
 
To change the deployment version number, author info and etc, you need to open the properties window then click the deployment project and it will display that info in a grid the same as it would properties for tools. It might take abit to get it right, you can also choose the default installation loaction and etc in that window. That info is also displayed when the user access's the program information in the properties window for the app. Although this might not be exactly what you are looking for as i have absolutley no vb6 experience.
 
jwmii2,

I appreciate you're taking the time to answer, but that's not what I'm looking for.

I was looking for a way to automatically include the program's revision number in the title bar so that, if one of the user's called me and complained about something, I could find out at a glance if they were running the latest version of the program.

But thanks.
 
Look at the Assembly object and it's collections. For example, the version can be returned using the following syntax:

Assembly.GetExecutingAssembly.GetName.Version

Hope this helps.

Glen Appleton

VB.Net student.
 
I forgot to add that almost all properties have a .ToString method, so you could use the following to return a string:

Assembly.GetExecutingAssembly.GetName.Version.ToString

Glen Appleton

VB.Net student.
 
Just to add to BuGlen's excellent answer, the .Version property returns a Version object, which has properties for:
[tt]
Major Returns the value of the Major component of the version number
Minor Returns the value of the Minor component of the version number
Build Returns the value of the build component of the version number
Revision Returns the value of the Revision component of the version number
[/tt]
This is nice, because you can use it (perhaps) to compare this assembly's version number against one on a server somewhere, which would let you know if a newer version were available. You would compare them in decreasing order to see if it were different. Or, use the version numbers from the server to build a new Version object, after which you can use the less-than-or-equal operator ( <= ) to see if they're different.
Code:
Dim myVersion, serverVersion As Version
myVersion = Assembly.GetExecutingAssembly.GetName.Version

' Go get values from 'master' copy on server
'    -- do some magic here to do this --

' Create new Version object
serverVersion = New Version(serverMajor, serverMinor, serverBuild, serverRevision)

' Compare them
If myVersion <= serverVersion Then
   ' Update required!
End If
One thing I wish they had included is the DateTime when the assembly got built. You can't trust the values from the filesystem for this. :-( And it would be nice to display that in a program info dialog box.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Whoops!

No need to update if the versions are the same. Just use the less-than operator ( < ) instead of the less-than-or-equal operator.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
I really appreciate all of your help, but when I try to use the &quot;Assembly&quot; object, my compiler/editor doesn't recognize it.
 
Try dropping back to the system object and building forward:

System.Reflection.Assembly.GetExecutingAssembly.GetName.Version

Glen Appleton

VB.Net student.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top