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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a problem with the VBA split function

Status
Not open for further replies.

hans37

Technical User
Aug 30, 2001
5
NL
I have the following problem. I have a string with different surnames seperated by " ". I want to make a function that gives me the first letter of the second surname (In reality what I want to do is more complex). I made the following function:

Public Function Aanschrijfnaam(VoorNamen) As String
Dim Voorletters(10) As Variant
Voorletters = Split(VoorNamen)
Aanschrijfnaam = Left(Voorletters(2), 1)
End Function

But this doesn't work. The compiler says there is something wrong with: voorletters = Split (VoorNamen); what is wrong?

 
Split is included w/ Access 2K. If you are using ver '97, search for basSplit in these forums. It was posted as a tool fo users of earlier version(s).

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
I stand correct. Thanks for pointing that out MichaelRed.

According to the object browser, Split accepts as string as the First argument. I think perhaps your problem is in that you are passing an array to the function. Tyrone Lumley
augerinn@gte.net
 
I stand corrected. Thanks for pointing that out MichaelRed.

According to the object browser, Split accepts as string as the First argument. I think perhaps your problem is in that you are passing an array to the function. Tyrone Lumley
augerinn@gte.net
 
If all you want is the first letter of the second name isn't this equivalent to finding the first character after the first space?

For x = 1 to len(String)
If mid$(string,x,1) = " " then
FirstLetter = Mid$(string, x + 1, 1)
Exit for
End if
Next x

Uncle Jack

"There is never enough money to hire a programmer, but always enough to train one."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top