On Thu, May 3, 2007 11:17 am, Daniel Brown wrote: > Function CantidadEnLetra(tyCantidad As Currency) As String function CantidadEnLetra ($tyCantidad) { /* > Dim lyCantidad As Currency, lyCentavos As Currency, lnDigito As Byte, > lnPrimerDigito As Byte, lnSegundoDigito As Byte, lnTercerDigito As > Byte, > lcBloque As String, lnNumeroBloques As Byte, lnBloqueCero */ > tyCantidad = Round(tyCantidad, 2) $tyCantidad = round($tyCantidad, 2); > lyCantidad = Int(tyCantidad) $lyCantidad = (int) $tyCantidad; //or IntVal > lyCentavos = (tyCantidad - lyCantidad) * 100 $lyCentavos = ($tyCantidad - $lyCantidad) * 100; > laUnidades = Array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", > "SIETE", > "OCHO", "NUEVE", "DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", > "DIESISEIS", "DIESISIETE", "DIESIOCHO", "DIESINUEVE", "VEINTE", > "VEINTIUN", > "VEINTIDOS", "VEINTITRES", "VEINTICUATRO", "VEINTICINCO", > "VEINTISEIS", > "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE") $laUnidades = array(...); > laDecenas = Array("DIEZ", "VEINTE", "TREINTA", "CUARENTA", > "CINCUENTA", > "SESENTA", "SETENTA", "OCHENTA", "NOVENTA") > laCentenas = Array("CIENTO", "DOSCIENTOS", "TRESCIENTOS", > "CUATROCIENTOS", > "QUINIENTOS", "SEISCIENTOS", "SETECIENTOS", "OCHOCIENTOS", > "NOVECIENTOS") $laDecenas = array(...); > lnNumeroBloques = 1 $luNumeroBloques = 1; > Do do { > lnPrimerDigito = 0 > lnSegundoDigito = 0 > lnTercerDigito = 0 > lcBloque = "" > lnBloqueCero = 0 //I refuse to re-type these with $ in front at this point. You do it. //In fact, from here on, I only translate any "new" syntax > For i = 1 To 3 for ($i = 1; $i <= 3; $i++){ > lnDigito = lyCantidad Mod 10 $lnDigito = $lyCantidad % 10; > If lnDigito <> 0 Then if ($lnDigito != 0){ // <> might actually work in php as well... > Select Case i switch ($i){ > Case 1 case 1: > lcBloque = " " & laUnidades(lnDigito - 1) $lcBloque = " " . laUnidades($lnDigito - 1); > lnPrimerDigito = lnDigito //$ and ; > Case 2 case 2: > If lnDigito <= 2 Then > lcBloque = " " & laUnidades((lnDigito * 10) + lnPrimerDigito - 1) > Else > lcBloque = " " & laDecenas(lnDigito - 1) & IIf(lnPrimerDigito <> 0, " > Y", > Null) & lcBloque $lcBloque = " " . laDecenas($lnDigito - 1) . ($lnPrimerDigito != 0 ? " Y" : '') . $lcBloque; > End If } > lnSegundoDigito = lnDigito > Case 3 > lcBloque = " " & IIf(lnDigito = 1 And lnPrimerDigito = 0 And > lnSegundoDigito > = 0, "CIEN", laCentenas(lnDigito - 1)) & lcBloque Use && in PHP for And in VB or whatever this is. > lnTercerDigito = lnDigito > End Select } > Else > lnBloqueCero = lnBloqueCero + 1 > End If > lyCantidad = Int(lyCantidad / 10) > If lyCantidad = 0 Then > Exit For break; //get out of for loop > End If } > Next i } > Select Case lnNumeroBloques > Case 1 > CantidadEnLetra = lcBloque > Case 2 > CantidadEnLetra = lcBloque & IIf(lnBloqueCero = 3, Null, " MIL") & > CantidadEnLetra > Case 3 > CantidadEnLetra = lcBloque & IIf(lnPrimerDigito = 1 And > lnSegundoDigito = 0 > And lnTercerDigito = 0, " MILLON", " MILLONES") & CantidadEnLetra > End Select > lnNumeroBloques = lnNumeroBloques + 1 > Loop Until lyCantidad = 0 I've lost track of where this "loop" is going at this point, because the indentation of the macro is non-existent... Indent the PHP code correctly, and it should get pretty clear. > CantidadEnLetra = "(" & CantidadEnLetra & IIf(tyCantidad > 1, " PESOS > ", " > PESO ") & Format(Str(lyCentavos), "00") & "/100 M.N. )" Format is probably some variant of http://php.net/sprintf > End Function } > > On 5/3/07, Tijnema ! <tijnema@xxxxxxxxx> wrote: >> >> On 5/3/07, Daniel Brown <parasane@xxxxxxxxx> wrote: >> > >> > Sie nicht auch sprechen Spanischen, Tij? >> >> Nein, aber mein deutsch ist also nicht gut ;) Sprechen sie >> Spanischen >> Daniel?\ >> >> Tijnema >> > >> > >> > >> > On 5/3/07, Tijnema ! <tijnema@xxxxxxxxx> wrote: >> > > >> > > On 5/2/07, Anton Krall <akrall-lists@xxxxxxxxxxxxxxx > wrote: >> > > > Guys.. I have a problem and I was wondering if somebody with >> good >> php >> > > > knowledge could help. >> > > > >> > > > I have this excel macro that converts number currency >> (mexican) into >> a >> > > > string and I was wondering if somebody could help translating >> it to >> > php... >> > > > >> > > > Her eis the macro, if you could help, I would really >> appreciate it. >> > > > >> > > > Thanks guys! >> > > >> > > I think that starting over is better then trying to convert this >> excel >> > > macro. What exactly do you want to convert, from ?? to ?? >> > > Since all functions are in a language that isn't english, dutch, >> > > german or frisian, I can't understand. >> > > > >> > > <snip> >> > > > laUnidades = Array("UN", "DOS", "TRES", "CUATRO", "CINCO", >> "SEIS", >> > "SIETE", >> > > > "OCHO", "NUEVE", "DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", >> "QUINCE", >> > > > "DIESISEIS", "DIESISIETE", "DIESIOCHO", "DIESINUEVE", >> "VEINTE", >> > "VEINTIUN", >> > > > "VEINTIDOS", "VEINTITRES", "VEINTICUATRO", "VEINTICINCO", >> "VEINTISEIS", >> > > > "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE") >> > > > laDecenas = Array("DIEZ", "VEINTE", "TREINTA", "CUARENTA", >> "CINCUENTA", >> > > > "SESENTA", "SETENTA", "OCHENTA", "NOVENTA") >> > > > laCentenas = Array("CIENTO", "DOSCIENTOS", "TRESCIENTOS", >> > "CUATROCIENTOS", >> > > > "QUINIENTOS", "SEISCIENTOS", "SETECIENTOS", "OCHOCIENTOS", >> > "NOVECIENTOS") >> > > Nice array, if you need it, you can use it directly in PHP, just >> add a >> > > $ sign before the variable and ; at the end, and it is a PHP >> array :) >> > > <snip> >> > > >> > > I've snipped the rest of your code, because it's very though to >> > > understand the code if you can't read the language. Like i said, >> show >> > > me what you want to convert from and to, so that i can help you >> > > writing something new, or comment your own macro in english so >> that >> > > people can understand it. >> > > >> > > Tijnema >> > > >> > > -- >> > > PHP General Mailing List (http://www.php.net/) >> > > To unsubscribe, visit: http://www.php.net/unsub.php >> > > >> > > >> > >> > >> > >> > -- >> > Daniel P. Brown >> > [office] (570-) 587-7080 Ext. 272 >> > [mobile] (570-) 766-8107 >> > > > > -- > Daniel P. Brown > [office] (570-) 587-7080 Ext. 272 > [mobile] (570-) 766-8107 > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php