Solved

find number in string

Posted on 2012-03-28
2
350 Views
Last Modified: 2012-03-28
Hello.

Can someone guide me on how to write - or possibly somebody has a solution to writing a function, which will return n-th number from a given string

The function arguments would be: (string, n), where n is n-th number in that string
Mind that my strings are only in that format - maybe it will be helpful:

string1: 7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7;7
string2: 9;8;10;10;8;8;8;8;8;10;10;8;8;8;8;8;10;10;8;8;8;8;8;10;10;8;8;8;8;8;10
string3: 8;8;10;10;8;8;8;8;8;10;10;8;8;8;8;8;10;10;8;8;8;8;8;10;10;8;8;8;8;8;10

So, the function
findNTH(string1, 6) would return 7
findNTH(string2, 2) would return 8
findNTH(string3, 3) would return 10

VBA please.
0
Comment
Question by:Lukasz Chmielewski
2 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 37778707
Use the Split() function, which based on a delimiter, will split a string into a single dimension array.  You can then walk the array from 1 to UBound() to read each of the elements or if you know that the string was all numbers, you can simply read myArray(nth)

Jim.
0
 
LVL 27

Author Closing Comment

by:Lukasz Chmielewski
ID: 37778722
Thanks
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

911 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

25 Experts available now in Live!

Get 1:1 Help Now