Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

returning the nth character in a string

Status
Not open for further replies.

Luis939

MIS
Feb 28, 2003
453
US
In continuation with a thread i started a while ago

thread707-508787 there a simple function that returns, say the 1st, 2nd, 3rd, etc character in a string
i know i can use the mid function and functions like that to isolate one or more characters, but just out of curiosity is there a simpler way to return just the third character without any indirect instructions, thanks!!
 
yea i know, but i just wanted to know if theres one direct function that says return character-n , not a function like the mid function that says starts at position 3 and collect just one character, but thanks anyway!
 
Yea i knew that syntax was of another language lol!
 
Write your own:
[blue]
Code:
  =ThirdChar(A1)
[/color]

You can implement it this way:
[blue]
Code:
Function ThirdChar(AString As String) As String
  ThirdChar = Mid(AString, 3, 1)
End Function
[/color]

 
Oh yea i never thought about writing my own function, there so many VBA pre-defined functions, its as if you think they will cover everything you ever need, but nope cant be that trusting, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top