DougInCanada
Technical User
I'm a VB.NET newbie but have worked with VB5 & 6 moons ago, and I'm finally giving in to .NET from vbscripting...
The following vbs code was in a script used to create users. It takes into account any hyphens, apostrophes in either the first or last names, as well as corrects for Mc and Mac. Finally, it capitalizes the first letters of the appropritate names. It uses the following function:
Which is called several times, for example:
While I used to use CreateObject in vbs, I've read that I should use
at the start of your source code (please correct me if I'm wrong).
Can someone provide some assistance with the .NET syntax for the function and/or the call?
I'm already struggling with the concepts, but I'm very pleased with what I see so far in VB 2010....
Much appreciated,
Doug
The following vbs code was in a script used to create users. It takes into account any hyphens, apostrophes in either the first or last names, as well as corrects for Mc and Mac. Finally, it capitalizes the first letters of the appropritate names. It uses the following function:
Code:
Function ReplacerFunction(wholematchstring,match1,match2,matchpos,source)
if len(match1)>1 then
'deal with inconvenient fact that the Mcs and Macs are longer than one char
match1=ucase(left(match1,1)) & trim(right(match1 & " ", len(match1)))
end if
ReplacerFunction = match1 & ucase(match2)
end function
Which is called several times, for example:
Code:
If InStr(strLastName, "-") > 0 then
Set myReplacer = getRef("ReplacerFunction")
With Createobject("vbscript.regexp")
.Global = True
.Multiline = True
.pattern = "(^mc|^mac|^|-|')(\w{1})"
strLastName = .Replace(strLastName, myReplacer)
End With
end if
While I used to use CreateObject in vbs, I've read that I should use
Code:
Imports System.Text.RegularExpressions
Can someone provide some assistance with the .NET syntax for the function and/or the call?
I'm already struggling with the concepts, but I'm very pleased with what I see so far in VB 2010....
Much appreciated,
Doug