Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5969677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:15:52+00:00 2026-05-22T20:15:52+00:00

I have a fairly lengthly block of code that I’m trying to convert from

  • 0

I have a fairly lengthly block of code that I’m trying to convert from VB6 to VB.NET. The ArcObjects GIS code basically looks at a table and groups a bunch of GIS layers together and adds them to the ArcMap table of contents. I’m having trouble with this line when testing it in Visual Studio 2010:

The VB6 line was this:

Dim pEnumVar As IEnumVersionInfo, value As Varient 

Add I was told it needed to be converted to this:

Dim pEnumVar As System.Collections.IEnumerator, value As Object  'I also tried value as String

Also, I had to change this line(4x):

value = pEnumVar.Next

To this:

value = pEnumVar.Current 'and I tried this value = pEnumVar.MoveNext

The VB6 version “value” was returning a string, and the .NET version “value” is returning a “” or null. How do I get “value” to return a string? Here is the long code.

Thanks

        Dim pLayer As ILayer
        Dim pGrpLayer As IGroupLayer

        Dim pStdTableColl As IStandaloneTableCollection
        Dim pStdTable As IStandaloneTable = Nothing
        Dim pTable As ITable = Nothing
        Dim pTableSort As ITableSort
        Dim pTblSortLyrs As ITableSort
        Dim pRowLyrs As IRow
        Dim pDataStat As IDataStatistics
        Dim pCursor As ICursor
        Dim pLyrCursor As ICursor
        Dim pQf As IQueryFilter

        Dim lngFldLayerName As Long
        Dim lngFldPath As Long
        Dim lngFldGroupOrder As Long
        Dim lngFldGroupName As Long
        Dim lngFldGroupTOCOrder As Long
        Dim lngFldGroupVis As Long
        Dim i As Integer

        Dim strLayerName As String
        Dim strPath As String
        Dim lngGroupTOCOrder As Long
        Dim blnGroupVis As Boolean

        Dim pEnumVar As IEnumVersionInfo, value As Object ' <<<<<<<<<<<<<<<<<<

        Dim pODGSLyr As New ODGSLayer

        'Start
        'Find the Layer Files metadata table
        pStdTableColl = m_pMap
        For i = 0 To pStdTableColl.StandaloneTableCount - 1
            pStdTable = pStdTableColl.StandaloneTable(i)
            If pStdTable.Name = "ODGSLAYERS" Then
                pTable = pStdTable
                lngFldLayerName = pTable.FindField("LAYERNAME")
                lngFldPath = pTable.FindField("PATH")
                lngFldGroupOrder = pTable.FindField("GROUPORDER")
                lngFldGroupName = pTable.FindField("GROUPNAME")
                lngFldGroupTOCOrder = pTable.FindField("GROUPTOCORDER")
                lngFldGroupVis = pTable.FindField("GROUPVISABLE")
            End If
        Next i

        If pStdTable Is Nothing Then
            Exit Sub
        End If

        'Sort the Table
        pTableSort = New TableSort
        With pTableSort
            .Fields = "GROUPTOCORDER, GROUPNAME"
            .Ascending("GROUPTOCORDER") = True
            .Ascending("GROUPNAME") = True
            .QueryFilter = Nothing
            .Table = pTable
        End With
        pTableSort.Sort(Nothing)

        pCursor = pTableSort.Rows

        'Find Unique Values in the Table
        pDataStat = New DataStatistics
        pDataStat.Field = "GROUPNAME"
        pDataStat.Cursor = pCursor

        pEnumVar = pDataStat.UniqueValues
        value = pEnumVar.Current ' <<<<<<<<<<<<<<<<<<<<<<<<<<

        Do Until IsDBNull(value)
            'Now resort the table based upon the layer order in the group
            pQf = New QueryFilter
            pQf.WhereClause = "[GROUPNAME] = '" & value & "'"
            pLyrCursor = pTable.Search(pQf, False)
            pTblSortLyrs = New TableSort
            With pTblSortLyrs
                .Fields = "GROUPORDER"
                .Ascending("GROUPORDER") = True
                .QueryFilter = pQf
                .Table = pTable
            End With
            pTblSortLyrs.Sort(Nothing)

            'Get the newly sorted rows and create the new Group and Layers inside the Group
            pLyrCursor = pTblSortLyrs.Rows
            pRowLyrs = pLyrCursor.NextRow

            'Create the new Group
            lngGroupTOCOrder = pRowLyrs.Value(lngFldGroupTOCOrder)
            blnGroupVis = pRowLyrs.Value(lngFldGroupVis)

            pGrpLayer = New GroupLayer
            pGrpLayer.Visible = blnGroupVis
            pGrpLayer.Expanded = False
            pGrpLayer.Name = pRowLyrs.Value(lngFldGroupName)

            'Add layers to the new Group
            Do Until pRowLyrs Is Nothing
                strLayerName = pRowLyrs.Value(lngFldLayerName)
                strPath = pRowLyrs.Value(lngFldPath)

                pODGSLyr = New ODGSLayer
                pLayer = pODGSLyr.LoadLayer(strPath, strLayerName)
                pGrpLayer.Add(pLayer)
                pRowLyrs = pLyrCursor.NextRow
            Loop

            'Add the Group layer to the map
            m_pMap.AddLayer(pGrpLayer)
            m_pMap.MoveLayer(pGrpLayer, lngGroupTOCOrder)

            '        Debug.Print "value - " & value & vbTab & "GroupVis = " & blnGroupVis
            value = pEnumVar.Current ' <<<<<<<<<<<<<<<<<<

        Loop
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:15:53+00:00Added an answer on May 22, 2026 at 8:15 pm

    Iterating over an object looks like this:

    While iterator.MoveNext() Do
      val=iterator.Current
    
      'do work with val here
    End While
    

    What you’re doing is calling Current without first moving the iterator in place (and then calling Current at the end for no reason).

    By the way, that whole mess is equivalent to:

    For Each val in list 'or whatever the source object is
      ' use val
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple const struct in some C code that simply holds
I have a fairly complex multi threaded application (server) that from time to time
I have a fairly large text file that I would like to convert into
I have a fairly small MySQL database (a Textpattern install) on a server that
I have a fairly simple ASP.NET 2.0 menu control using a sitemap file and
I have a fairly standards compliant XHTML+CSS site that looks great on all browsers
I have a fairly large codebase that depends on MooTools v1.11 and am about
We have a fairly complicated GUI in windows forms using C# and .Net 2.0.
I have a fairly simple game that works perfectly on every version now up
I have a fairly large work project that uses pygtk for the GUI and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.