Solved

How do I read in a version text string and extract each integer into a variable using batch file or vb.

Posted on 2013-12-29
3
263 Views
Last Modified: 2013-12-29
How do I read in a version text string and extract each integer into a variable using batch file along with the position.
example: 3.2.13.0, 3
Need to return 13

If i pass in the version number and the position i get the integer at that position.
0
Comment
Question by:josephh610
  • 2
3 Comments
 
LVL 10

Expert Comment

by:JEaston
ID: 39745147
If using VBS then the following code will do what you want:

VersionArr = Split(Wscript.Arguments.Item(0),".")
WScript.Echo VersionArr(Wscript.Arguments.Item(1)-1)

Open in new window


However, you do not need the comma to separate the arguments.

Therefore:  3.2.13.0 3
Will return 13.  (i.e. only a space, no comma).
0
 

Author Comment

by:josephh610
ID: 39745159
Cool that works, how do i assign it to a variable that I can now use externally?
0
 
LVL 10

Accepted Solution

by:
JEaston earned 350 total points
ID: 39745168
On line 2, replace WScript.Echo with 'variablename = '

E.g.
VersionArr = Split(Wscript.Arguments.Item(0),".")
versionpart = VersionArr(Wscript.Arguments.Item(1)-1)

Open in new window


You can then use that variable as you please.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Vb.Net Menu 1 22
regex to allow alphanumeric characters and \ 2 23
Copy/Clone an object. 9 15
Getfiles in vb.net 28 22
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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