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 30-11-2010
Alejo15x Alejo15x is offline
Miembro
 
Registrado: ene 2010
Posts: 55
Poder: 15
Alejo15x Va por buen camino
Could not convert variant of type (Null) into type (Integer)

Hola!

Tengo un problemita con el cual nunca eh lidiado.
Es en sistemas XML, en el cual estoy usando un entero, pero aveces cierta función no existe osea NULA, de modo que no encuentra el entero y me tira error.

Código:
Could not convert variant of type (Null) into type (Integer)
Código Delphi [-]
    case OutfitsList.Outfit[tempOutfitId].Premium of
      0 :
        boolPremiumOutfit.Checked := false;
      1 :
        boolPremiumOutfit.Checked := true;
    end;
Responder Con Cita
  #2  
Antiguo 30-11-2010
Avatar de Estifmauin
Estifmauin Estifmauin is offline
Miembro
 
Registrado: may 2008
Ubicación: Alicante
Posts: 24
Poder: 0
Estifmauin Va por buen camino
Simplemente, antes de entrar en el case, comprueba si el valor es nulo, y en caso afirmativo asígnale el valor x defecto:

Código Delphi [-]
if OutfitsList.Outfit[tempOutfitId].Premium = NULL then
    boolPremiumOutfit.Checked := false //el valor x por defecto
else
    // entras en el case
para evaluar la constante NULL, debes incluir uses variant, aunque supongo que ya lo tienes.

OJO: compara con NULL, no con nil. Son cosas distintas.
Responder Con Cita
  #3  
Antiguo 30-11-2010
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.233
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
También puedes utilizar la función VarIsNull() especficamente diseñada para ello.

Código Delphi [-]
  if VarIsNull(OutfitsList.Outfit[tempOutfitId].Premium ) then begin

    // lo que sea si es nulo
    ...
  end
  else begin
    case OutfitsList.Outfit[tempOutfitId].Premium of
      0 :
        boolPremiumOutfit.Checked := false;
      1 :
        boolPremiumOutfit.Checked := true;
    end;
  end;
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Sql que no retorna datos me da error:invalid variant type conversion bezaig SQL 6 17-03-2010 09:58:53
type? Ledian_Fdez C++ Builder 1 05-02-2010 21:53:42
problema con type anubis Varios 1 06-05-2007 22:24:37
type needs finalization henrygale Varios 2 13-02-2007 17:49:44
Type Memo emeritos Conexión con bases de datos 1 07-11-2003 15:40:06


La franja horaria es GMT +2. Ahora son las 15:45:01.


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