CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Converting VBA function to PHP function

Print topic Send  topic

Author Message
NerishaB

Posts: 25
Posted: 10/05/2010, 1:11 AM

Hi,

I have a VBA function, that I have attempted to converted to PHP. Now, I am very new to this, and dont know how to properly call a function, so I had attempted to remove the code from the function, and have the entire code in the beforeShow event of a label. Here is the VBA code:

Function SWAPLETTERS(ByVal InputString As String) As String
Dim i As Long
Dim j As Long
Dim LeftString As String
Dim RightString As String

j = Len(InputString) \ 2 + 1
LeftString = Left$(InputString, j)
RightString = Mid$(InputString, Len(LeftString) + 1)

For i = 1 To Len(LeftString)
SWAPLETTERS = SWAPLETTERS & Mid$(LeftString, i, 1) & Mid$(RightString, i, 1)
Next
End Function

I am having trouble converting the statement :
SWAPLETTERS = SWAPLETTERS & Mid$(LeftString, i, 1) & Mid$(RightString, i, 1).

Here is my PHP code:
$KeyString = CCGetParam("key");
$Split = round(strlen($KeyString) / 2) + 1;
$LeftString = substr($KeyString, 0, $Split - 1 );
$RightString = substr($KeyString, StrLen($LeftString));
$Label2->SetText($LeftString);
$Label4->SetText($RightString);
$Unscrambled = ' ';
For ($i = 0; $i<StrLen($KeyString); $i++) {
$Unscrambled = $Unscrambled . subStr($LeftString, $i, 1) . subStr($RightString, $i, 1);
}
$Label3->SetText($Unscrambled);

Can someone help me convert the line I specified above. My line:
$Unscrambled = $Unscrambled . subStr($LeftString, $i, 1) . subStr($RightString, $i, 1);
does not work.
View profile  Send private message
ab5ni


Posts: 168
Posted: 10/09/2010, 5:53 PM

Off the top of my head, and just glancing at the code, I'd say it has something to do with rounding. What will it do odd-length strings? Have u worked out the math? Is it rounding up or down.

Regards

_________________
Randall Jouett
Amateur Radio: AB5NI
I eat spaghetti code out of a bit-bucket while sitting at a hash table! And yes, I paid for the meal in cache!


View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.