CodeCharge Studio
search Register Login  

Visual PHP Web Development

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Converting VBA function to PHP function

Print topic Send  topic

Author Message

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


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)
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));
$Unscrambled = ' ';
For ($i = 0; $i<StrLen($KeyString); $i++) {
$Unscrambled = $Unscrambled . subStr($LeftString, $i, 1) . subStr($RightString, $i, 1);

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

Posts: 177
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.


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

Internet Database

Visually create Web enabled database applications in minutes.

Home   |    Search   |    Members   |    Register   |    Login

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