elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
28 Mayo 2012, 23:35  


Tema destacado: Suscripción al boletín mensual de elhacker.net

+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General (Moderador: Littlehorse)
| | |-+  [SRC] [Delphi] Text_Beetwen_Words [by *PsYkE1*]
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [SRC] [Delphi] Text_Beetwen_Words [by *PsYkE1*]  (Leído 791 veces)
Psyke1
Wiki

Desconectado Desconectado

Mensajes: 1.005



Ver Perfil WWW
[SRC] [Delphi] Text_Beetwen_Words [by *PsYkE1*]
« en: 23 Agosto 2010, 18:37 »

Hola, me he pasado a Delphi hace dos dias y he pasado esta funcion que tenia hecha en VB6...  :P

http://foro.rthacker.net/programacion-visual-basic/%28src%29-%28funcion%29-text_between_words-%28by-*psyke1*%29/

Código
(* * * * * * * * * * * * * * * * * * * * * * * * * *)
(* Function : Text_Beetwen_Words                   *)
(* Author   : *PsYkE1*                             *)
(* Mail     : vbpsyke1@mixmail.com                 *)
(* Date     : 24/8/10                              *)
(* Purpose  : Returns text which is beetwen        *)
(*            two words.                           *)
(* Visit    : http://foro.rthacker.net/            *)
(* * * * * * * * * * * * * * * * * * * * * * * * * *)
 
function InStr(iStart: integer; sText: string; sWord: string): integer;
begin
Result := Pos(sWord,Copy(sText,iStart,Length(sText) - (iStart - 1)));
end;
 
function Text_Beetwen_Words(sTextToAnalyze:String ; sStartWord:String ; sEndWord:string): String;
var
 iPosition1  : Integer;
 iPosition2  : Integer;
 iStart      : Integer;
begin
    iPosition1 := Instr(1,sTextToAnalyze,sStartWord);
    if iPosition1 > 0 then
     begin
       iStart := (iPosition1 + Length(sStartWord));
       iPosition2 := Instr(iStart,sTextToAnalyze,sEndWord);
     end
    else
     exit;
    if iPosition2 > 0 then
     Result := Copy(sTextToAnalyze,iStart,iPosition2 -1);
end;

Un ejemplo:
Código
procedure TForm1.FormCreate(Sender: TObject);
   begin
     (* añade un textbox *)
   edit1.Text:= text_beetwen_words('Hoy estoy muy aburrido','Hoy ',' aburrido');
   end;
 
end.

Devuelve esto:
Citar
estoy muy

DoEvents¡! :P


« Última modificación: 26 Agosto 2010, 16:46 por *PsYkE1* » En línea

VanHan

Desconectado Desconectado

Mensajes: 41


.:: [ vHn ] ::.


Ver Perfil WWW
Re: [Delphi] Text_Beetwen_Words [by *PsYkE1*]
« Respuesta #1 en: 24 Agosto 2010, 02:23 »

Me encanto  ;D Lindo Source

Salu2
[vHn]


En línea

.:: I'm GeeK ::.
Psyke1
Wiki

Desconectado Desconectado

Mensajes: 1.005



Ver Perfil WWW
Re: [Delphi] Text_Beetwen_Words [by *PsYkE1*]
« Respuesta #2 en: 24 Agosto 2010, 02:40 »

Gracias, ire pasando mis funciones de vb a delphi progresivamente...

DoEvents¡! :P
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines