Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 14-05-2004
atirado atirado is offline
Miembro
 
Registrado: mar 2004
Posts: 41
Poder: 0
atirado Va por buen camino
Lightbulb Función para validar datos numéricos simples en un Edit de INTRAWEB

Hola a todos!
Les paso una funcioncita que he visto por aquí que muchos han buscado. Sirve para validar números en INTRAWEB, ya que, como quienes lo han visto funcionar saben no existen máscaras (al menos yo no he encontrado) para los Edit.

Código:
{===============================================================================
  Propósito: Comprobar si el contenido de un campo Edit es numérico.
  Parámetros: El texto contenido dentro del Edit.
  V. salida: Un valor de tipo booleano que indica si el campo es numérico o no.
  Codificada por: Lic. Alejandro Tirado Luna (MTI 03)
===============================================================================}
Function esNumerico(S: String): Boolean;
var
   i, ultimapos, k : integer;
   flag, punto : boolean;
begin
   i	 := 1;
   flag  := true;
   punto := false;
   ultimapos := length(s);
   while (i <= length(s)) do
   begin
	  If i = 1 then
	  begin
		If s[i] = '.' then
		begin
		  flag  := false;
		  i := length(s)+1;
		end
		else
			If s[i] in ['0'..'9', '-'] then
			  flag := true
			else
			begin
				flag := false;
				i := length(s)+1;
			end;
	  end
	  else
	  begin
		If i = ultimapos then
		begin
		  If s[i] = '.' then
		  begin
			flag := false;
			i := length(s)+1;
		  end
		  else
			  If s[i] in ['0'..'9'] then
			  begin
				If s[i-1] in ['0'..'9', '.'] then
				  flag := true
				else
				begin
				   flag := false;
				   i := length(s)+1;
				end;
			  end
			  else
			  begin
				  flag := false;
				  i := length(s)+1;
			  end;
		end
		else
		begin
		  If i = ultimapos -1 then
		  begin
			If s[i] = '.' then
			  If s[i+1] in ['0'..'9'] then
				flag := true
			  else
			  begin
				  flag := false;
				  i := length(s)+1;
			  end
			else
				If s[i] in ['0'..'9'] then
				  If s[i+1] in ['0'..'9'] then
					flag := true
				  else
				  begin
					   flag := false;
					   i := length(s)+1;
				  end;
		  end
		  else
		  begin
			   If s[i] = '.' then
			   begin
				  for k := (i-1) downto 1 do
					 if s[k] = '.' then
					 begin
					   flag := false;
					   i := length(s)+1;
					 end;
				  for k := (i+1) to length(s) do
					 if s[k] = '.' then
					 begin
					   flag := false;
					   i := length(s)+1;
					 end;
			   end
			   else
			   begin
				  if s[i] in ['0'..'9'] then
					flag := true
				  else
				  begin
					 flag := false;
					 i := length(s)+1;
				  end;
			   end;
		  end;
		end;
	  end;
	  Inc(i);
   end; //while
   result := flag;
end;
Espero les sirva a quienes están trabajando con IntraWeb
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 02:11:47.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi