Solved

find number in string

Posted on 2012-03-28
2
346 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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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 …
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…

762 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

13 Experts available now in Live!

Get 1:1 Help Now