Solved

find number in string

Posted on 2012-03-28
2
351 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 - finding skipped numbers 11 22
Data Type Mismatch in Criteria - Access 6 28
Access Open Report with SQL Parameter 11 28
IIF help, YN field 7 21
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

815 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

11 Experts available now in Live!

Get 1:1 Help Now