- #1
dunnome
- 7
- 0
Hello ! I have a php code that I'd like to use as a vbs one. But I don't know exacly how to do so. Could you help me please ?
Actually, my vbs script will read a file line by line, take the first word, put it in 'LastName' and after the space, take the "FirstName". But if you reverse the Last Name and the First Name, it'll be wrong. The purpose of it is that you can add numerous people in a server in one click, using a txt file
Here's a piece of my vbs script :
________________________________________________________________
space=" "
Do Until objFile.AtEndofStream
Strline=objFile.ReadLine
E1=InStr(Strline,space)
osn=Mid(Strline,1,E1-1) E2=Len(StrLine)
oGivenName=Mid(Strline,E1+1,E2)
oUname = Left(oGivenName,1) & "." & osn
_______________________________________________________________
In the php script, the code will know whether the name is in capital letter or not and will assign the First Name and the Last name correctly :
____________________________________________________________________
<?php
$Name="John DOE";
$temp = explode(" ", $nomprenom, 2);
if (strcmp($temp[0], strtoupper($temp[0])) === 0)
{
$LastName = $temp[0];
$FirstName= $temp[1];
}
else
{
$LastName= $temp[1];
$FirstName= $temp[0];
}
/* In order to know if it works, I display them */
echo $LastName;
echo "<br>";
echo $FirstName;
?>
__________________________________________________________________
I need to use that code in the vbs script. Can you help me do it please ? I don't really master the vbs language.
Thank you.
Actually, my vbs script will read a file line by line, take the first word, put it in 'LastName' and after the space, take the "FirstName". But if you reverse the Last Name and the First Name, it'll be wrong. The purpose of it is that you can add numerous people in a server in one click, using a txt file
Here's a piece of my vbs script :
________________________________________________________________
space=" "
Do Until objFile.AtEndofStream
Strline=objFile.ReadLine
E1=InStr(Strline,space)
osn=Mid(Strline,1,E1-1) E2=Len(StrLine)
oGivenName=Mid(Strline,E1+1,E2)
oUname = Left(oGivenName,1) & "." & osn
_______________________________________________________________
In the php script, the code will know whether the name is in capital letter or not and will assign the First Name and the Last name correctly :
____________________________________________________________________
<?php
$Name="John DOE";
$temp = explode(" ", $nomprenom, 2);
if (strcmp($temp[0], strtoupper($temp[0])) === 0)
{
$LastName = $temp[0];
$FirstName= $temp[1];
}
else
{
$LastName= $temp[1];
$FirstName= $temp[0];
}
/* In order to know if it works, I display them */
echo $LastName;
echo "<br>";
echo $FirstName;
?>
__________________________________________________________________
I need to use that code in the vbs script. Can you help me do it please ? I don't really master the vbs language.
Thank you.
Last edited: