dim firstLayer as ILayer dim dataSet as IDataset dim workSpace as IWorkspace dim strWorkingPath as String If TypeOf firstLayer Is IFeatureLayer Or TypeOf firstLayer Is IRasterLayer Then dataSet = firstLayer workSpace = dataSet.Workspace strWorkingPath = workSpace.PathName End If
If firstLayer.GetType().Equals(typeof(ESRI.ArcGIS.Carto.IFeatureLayer)) Then
If firstLayer.GetType().ToString().Equals("ESRI.ArcGIS.Carto.IFeatureLayer") Then
In Visual Basic 6.0, the TypeOf function is used in an If...Then...Else statement to determine whether an object reference is of a specified object type. In this context, a user-defined type is considered to be an object type.
In Visual Basic 2005, user-defined types (now known as structures) are not object types and cannot be evaluated by the TypeOf function.
' Modified code Dim m As MyType Dim mTest As MyType If m.GetType Is mTest.GetType Then ...
For i = 0 To map.LayerCount - 1 firstLayer = map.Layer(i)