First off let me apologize for posting to the wrong group. Secondly
thanks so much for the reply and actually doing the code. I will work
at getting this code incorporated into my page and working. I
appreciate your help and sorry again for clogging up your group with
classic ASP and not knowing the difference.
Thanks,
Ben
On Nov 11, 1:27 am, Cerebrus <[EMAIL PROTECTED]> wrote:
> This is not really a classic ASP group, but I can sense that telling
> you to find a more appropriate group would be profoundly unhelpful,
> because you aren't a professional developer.
>
> This is a typical example of code written without the slightest amount
> of prescience. Don't you just want to grab people who write such code
> by the scruff of their neck and shake them till they faint ?? ;-)
>
> I think it's a testament to how boring the day is going for me that I
> decided to write this code for you (VBScript, imagine !!) :
>
> I think it should work in most scenarios :
>
> ---
> Dim fullName
> fullName = "Mohandas Karamchand Gandhi"
>
> Const initialSeparator = "."
>
> Dim separators(3)
> separators(0) = "," 'Comma
> separators(1) = " " 'Space
> separators(2) = ";" 'Semicolon
> separators(3) = "-" 'Hypen
>
> 'Call the function with the first separator.
> GetInitials(0)
>
> Function GetInitials(byval i)
> Dim initials, namePart, allNames
> allNames = Split(fullName, separators(i))
>
> If UBound(allNames) > 1 Then
> 'If the Split succeeded, then try to find the initials.
> For Each namePart In allNames
> If Len(namePart) > 0 Then
> 'Get the first letter of this Name part and append it to the
> initials variable.
> initials = initials & UCase(Left(namePart, 1)) &
> initialSeparator
> End If
> Next
> Response.Write("The initials are: " & initials)
> Else
> 'If the Split failed, call this function recursively with the next
> separator.
> If i < UBound(separators) Then
> GetInitials(i + 1)
> Else
> Response.Write("The supplied name could not be parsed into its
> initials.")
> End If
> End If
> End Function
>
> ---
>
> Points to note :
>
> 1. You can provide any number of possible separators for the names.
> 2. You can modify the character used as a separator for the Output
> initials.
> 3. You will still need to adapt the code for your own scenario, so I
> have tried to provide explanatory comments.
>
> HTH.
>
> On Nov 11, 12:12 am, Ben <[EMAIL PROTECTED]> wrote:
>
> > Hello VB.Net members. I'm a Network/Server admin who has had some web
> > page maintenance thrown into my lap. We have an ASP page that is
> > coded with some VB that splits a field in two so that we can get the
> > First Letter of a persons first and last name. Below is the code that
> > does this...
>
> > dim strPatientFullName
> > strPatientFullName = Split(strPatientName2, ",")
> > strPatientName = left(strpatientfullname(0), 1) & ", " &
> > left(strpatientfullname(1), 2)
>
> > It looks for the comma to do the split. Here is my
> > problem...sometimes the users who do the input do not use a comma but
> > rather just a space. When this happens our program blows up and only
> > lists people up to the last person before the one w/ no comma. How
> > can I do some error handling on my site so I can do the split at the
> > comma and then if there is no comma have it check for a space and then
> > if there is no space have it just grab the first letter of the
> > strPatientFullName?
>
> > Any help is greatly appreciated and if I need to clarify something
> > please let me know.
>
> > Thanks,