?
Solved

find number in string

Posted on 2012-03-28
2
Medium Priority
?
369 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 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

840 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