在vb中按降序报告项目

时间:2019-07-02 05:02:32

标签: vb.net

使用以下代码,我可以检索所有ModelView名称,跳过8个视图并使用lw.writeline("Views: " & vw.Name.ToString)打印其他视图

但是我想按降序打印其他视图。

当前输出:

Views: gdfgfdg
Views: 15455
Views: NewView

所需的输出:

Views: NewView
Views: gdfgfdg
Views: 15455

代码:

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow

Dim displayPart As Part = theSession.Parts.Display
'Dim list As New List(Of String)

Dim ViewNames() As String
Dim views As ModelingViewCollection
views = workPart.ModelingViews

lw.open()
    For Each vw as ModelingView in views
       ' lw.writeline(temp.Name.ToString)
            Select Case vw.Name.ToString
                Case "Back"
                Case "Bottom" 
                Case "Front" 
                Case "Isometric" 
                Case "Left" 
                Case "Right" 
                Case "Top" 
                Case "Trimetric"
                Case Else
                    lw.writeline("Views: " & vw.Name.ToString) ''' Print deleted camera nodes
            End Select 
    Next       
lw.close()

1 个答案:

答案 0 :(得分:1)

For Each vw as ModelingView in views.OrderByDescending(Function(v) v.Name)

大概Name的类型为String,因此在这种情况下对其调用ToString毫无意义。

编辑:

如果您需要从IEnumerable(Of T)获得IEnumerable

For Each vw in views.Cast(Of ModelingView)().OrderByDescending(Function(v) v.Name)