|
-
Apr 30th, 2023, 04:38 AM
#1
Thread Starter
Junior Member
-
Apr 30th, 2023, 05:44 PM
#2
Re: Assembly Version Formatting
You can create a function to do this yourself:-
Code:
Private Function FormatVersion(ByVal version As String) As String
Return String.Join(".", From s In version.Split(".").Select(
Function(value, index)
If index = 2 OrElse index = 3 Then Return value.PadLeft(4, "0"c)
Return value
End Function))
End Function
Tested with this:-
Code:
Debug.WriteLine(FormatVersion("1.2.430.20"))
Produces this output:-
-
Apr 30th, 2023, 05:59 PM
#3
Re: Assembly Version Formatting
Here's a slightly more simplified version:-
Code:
Private Function FormatVersion(ByVal version As String) As String
Return String.Join(".", version.Split(".").
Select(Function(value, index) If(index = 2 OrElse index = 3, value.PadLeft(4, "0"c), value)))
End Function
-
Apr 30th, 2023, 07:37 PM
#4
Re: Assembly Version Formatting
The My.Application.Info.Version property is type Version and the Major, Minor, Build and Revision properties of that are type Integer. Numbers don't have leading zeroes, so you have to add them yourself if you want your string representation to contain them, e.g.
vb.net Code:
Dim v = My.Application.Info.Version
Dim versionText = $"{v.Major}.{v.Minor}.{v.Build}.{v.Revision:0000}"
-
May 1st, 2023, 02:07 AM
#5
Thread Starter
Junior Member
Re: Assembly Version Formatting
 Originally Posted by jmcilhinney
The My.Application.Info.Version property is type Version and the Major, Minor, Build and Revision properties of that are type Integer. Numbers don't have leading zeroes, so you have to add them yourself if you want your string representation to contain them, e.g.
vb.net Code:
Dim v = My.Application.Info.Version
Dim versionText = $"{v.Major}.{v.Minor}.{v.Build}.{v.Revision:0000}"
jmcilhinney,
Thanks for the help! So here's my new code and it works perfectly how I wanted it to. I'm going to do some other stuff now hahaha! That was brilliant and I appreciate it very much.
Thanks to everyone else who responded as well. I love this site and everyone who takes the time to reach out and help others in need. Hopefully one day I'll get to the point where I'm helping others as well haha.
Marking this as [Resolved]
-
May 1st, 2023, 02:09 AM
#6
Thread Starter
Junior Member
Re: Assembly Version Formatting
 Originally Posted by Niya
You can create a function to do this yourself:-
Code:
Private Function FormatVersion(ByVal version As String) As String
Return String.Join(".", From s In version.Split(".").Select(
Function(value, index)
If index = 2 OrElse index = 3 Then Return value.PadLeft(4, "0"c)
Return value
End Function))
End Function
Tested with this:-
Code:
Debug.WriteLine(FormatVersion("1.2.430.20"))
Produces this output:-
Not exactly what I was looking for, but thanks for reaching out. I do appreciate it.
-
May 1st, 2023, 02:11 AM
#7
Thread Starter
Junior Member
Re: Assembly Version Formatting
 Originally Posted by Niya
Here's a slightly more simplified version:-
Code:
Private Function FormatVersion(ByVal version As String) As String
Return String.Join(".", version.Split(".").
Select(Function(value, index) If(index = 2 OrElse index = 3, value.PadLeft(4, "0"c), value)))
End Function
Now this may be something more practical, but jmcilhinney's response is exactly what I was looking for.
I am going to give your suggestion on this option a try as I may be able to use it for my other application where I'm doing something a bit different. Thank you so much Niya for always looking out on my posts haha you have helped me in the past a great deal!!! So I'm always looking for your replies for sure! Thanks again.
-
May 1st, 2023, 02:55 AM
#8
Re: [RESOLVED] Assembly Version Formatting
jmc's solution is better than mine. Use that instead
-
May 3rd, 2023, 03:52 PM
#9
Re: [RESOLVED] Assembly Version Formatting
Because we did not have a versioning system and are relatively small I used this
Major - year
Minor - month
Build - day
Revision - a number or 24 hour time
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|