|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Having trouble comparing types...I want to compare types in a case statement.
ie. Select Case dr(i).GetType Case System.Double ' Double action here Case System.Date ' Date Action Here End Case If dr(i).GetType is GetType(System.Double) Then... ... works fine here, but put it in a case statement and wavy underlines appear. Cannot seem to understand the correct systax for the case statement usage in this scenario. Is this doable in a case statement? I'm probably overlooking something simple, but just can't see it. You can do this by getting the TypeCode of the type. This is available by
calling the Type.GetTypeCode method on the Type returned. -- Show quoteHTH, Kevin Spencer Microsoft MVP Professional Numbskull This is, by definition, not that. "Mike Edgewood" <itm***@gmail.com> wrote in message news:1148574013.660193.234450@y43g2000cwc.googlegroups.com... >I want to compare types in a case statement. > > ie. > Select Case dr(i).GetType > Case System.Double > ' Double action here > Case System.Date > ' Date Action Here > End Case > > > If dr(i).GetType is GetType(System.Double) Then... > ... works fine here, but put it in a case statement and wavy > underlines appear. > > Cannot seem to understand the correct systax for the case statement > usage in this scenario. Is this doable in a case statement? I'm > probably overlooking something simple, but just can't see it. > Still getting errors...
(where dr = sqldatareader; i = integer) Select Case dr(i).GetTypeCode ' results in late binding error ... Case Double.GetTypeCode ' error: Reference to a non-Shared member requires an object reference. .... Case is Double.GetTypeCode ' error: Relational operator expected. End Select Case Is, Case =, Case Is =, all error out. Select Case dr(0).GetType Case Is = GetType(System.Double) End Select ' Error: Operator "=" is not defined for types 'System.Type' and 'System.Type'. Can you show me an example? It is the syntax I am not understanding and an example would help me tremendously. |
|||||||||||||||||||||||