[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
Solved

# find number in string

Posted on 2012-03-28
Medium Priority
366 Views
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

0
Question by:Lukasz Chmielewski
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 58

Accepted Solution

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

ID: 37778722
Thanks
0

## Featured Post

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
###### Suggested Courses
Course of the Month12 days, 15 hours left to enroll