|
-
Feb 9th, 2000, 07:02 PM
#1
Thread Starter
Lively Member
I want to be able to get someone's first name from a string of text that contains their whole name. The problem is, the whole name has no space in it but the names have capital letters Eg:
SimonPearce
JoeBloggs
FredSmith
Can anyone work out how I can get a string that just says: Simon, Joe or Fred??
Thanks!
Simon
-
Feb 9th, 2000, 07:16 PM
#2
Frenzied Member
Try this;
Function FirstName(FullName As String) As String
Dim nCount As Integer
FirstName = ""
nCount = 1
While Left(FullName, nCount) = StrConv(Left(FullName, nCount), vbProperCase) And nCount <= Len(FullName)
FirstName = Left(FullName, nCount)
nCount = nCount + 1
Wend
End Function
Use it like this
[firstname]=FirstName("[fullname]")
eg;
Msgbox FirstName("MarkBeeton") would display a msgbox with "Mark" on it.
The code isn't wonderful but it should solve the problem.
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|