Re: question re: user account creation script




"Al Dunbar [MS-MVP]" <alan-no-drub-spam@xxxxxxxxxxx> wrote in message
news:OzcAkWOPHHA.3872@xxxxxxxxxxxxxxxxxxxxxxx

"Jeremy Schubert" <jschubert@no*spam.shaw.ca> wrote in message
news:%23Q5OFaLPHHA.324@xxxxxxxxxxxxxxxxxxxxxxx
I am almost finished creating a user creation script for a school.
It reads data from a csv file to create all the attributes etc.

1. Is the following line acceptable:
objUser,Put "Display Name" strFirst & " " & strLast

Syntactically wrong: comma should be a period, and the two string
expressions ("display name") and (srfirst & " " & strlast) need something
else between them, likely a comma.

2. The user is instructd to first create a spread *** with appropriate
colums and then convert that to a csv file and then a txt file. The
instructions also say to strip any characters other then alphabetical
characters (e.g. hyphen, comma, and space) from the names. Would it be
easy
to add lines to my script that double check that this has been done and
to
remove them if they haven't been. (If removing is a lot of work, I can
cancel the creation of that particular user account and write a note to
the
log file.). Would I basically use something like:

If instrFirst(",") or if instrFirst("-") or if instrFrist(" ")
Then (write log file entry and move on to next user)
EndIf
If instrLast(",") or if instrLast("-") or if instrLast(" ")
Then (write log file entry and move on to next user)
Else (continue on with script)

Depends on how much work you want to force onto the user, and whether or
not
simply stripping the characters you do not want will result in acceptable
attribute values, but you could do this either with a number of replace
commands (simple but repetitive and moderately inefficient), or with
regular
expressions (a bit more involved).

/Al

Thanks for the response Al.
1. You're right about the comma being a period.

2. I actually just found a solution on the web. I'm going to use the
following code to strip out 'illegal' characters so the script can carry on.
'This function find the 1st occurence of substring in a string and remove
it.

'LongStr: String to delete from
'SubStr: Substring to remove.

Public Function StrDel(LongStr As String, SubStr As String) As String
Dim Dest As Long, Src As Long

Dest = InStr(LongStr, SubStr)

If Dest = 0 Then
StrDel = ""
Exit Function
End If

Src = Dest + Len(SubStr)
Mid$(TempStr, Dest) = Mid$(TempStr, Src)
LongStr = Left$(LongStr, Len(LongStr) - Len(SubStr))

StrDel = LongStr

End Function


.