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

Convert VB6 Function to PHP 1

Status
Not open for further replies.

three57m

Programmer
Jun 13, 2006
202
US
Can anyone assist with converting this VB6 function to PHP

Code:
Private Function GenerateKeyNumber(MyName as String) As Long
    Dim i As Integer
    Dim S As String * 1
    Dim key As Long
    key = 0
    For i = 1 To Len(MyName)
        S = Mid(MyName, i, 1)
        key = key + Asc(S)
    Next i
    GenerateKeyNumber = Int(key * 14)
End Function
 
here is what i have pieced together so far:
Code:
function generatekey()
$i=1;
$key=0;
$myn=strlen(MyName);
do
	{
$onechar = substr(MyName,$i,1);
$key = $key + ord($onechar);
$i++;
while($i<=$myn)
$mykeynumber = $key * 14
}
 
Code:
function generateKey($name){
 $return = 0;
 for($i=0; $i< strlen($name); $i++){
   $return = $return + ord($name[$i}];
 }
 return intval($return * 14);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top