Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim aList As New List(Of AClass) From {
            New AClass With {.Item1 = "2", .Item2 = "", .Item3 = "", .Item4 = "", .Item5 = "10"},
            New AClass With {.Item1 = "1", .Item2 = "", .Item3 = "", .Item4 = "", .Item5 = "20"},
            New AClass With {.Item1 = "7", .Item2 = "", .Item3 = "", .Item4 = "", .Item5 = "30"},
            New AClass With {.Item1 = "2", .Item2 = "", .Item3 = "", .Item4 = "", .Item5 = "40"},
            New AClass With {.Item1 = "1", .Item2 = "", .Item3 = "", .Item4 = "", .Item5 = "50"},
            New AClass With {.Item1 = "1", .Item2 = "", .Item3 = "", .Item4 = "", .Item5 = "60"},
            New AClass With {.Item1 = "5", .Item2 = "", .Item3 = "", .Item4 = "", .Item5 = "70"}
        }

        Dim aa = aList.GroupBy(
            Function(group) New With
            {
                Key group.Item1
            }) _
            .Select(Function(group) New AClass() With
            {
                .Item1 = group.Key.Item1,
                .Item5 = group.Sum(Function(x) x.Item5)
            })
        For Each d As AClass In aa
            Debug.Print(d.Item1 + " " + d.Item5)
        Next

    End Sub

    Class AClass
        Public Property Item1 As String
        Public Property Item2 As String
        Public Property Item3 As String
        Public Property Item4 As String
        Public Property Item5 As String
    End Class
End Class
---

nullを変換しようとしてもエラーが出ないようにしたいのであれば、Convertクラスのメソッドを使う

@Html.HiddenFor(Function(model) model.TestData, New With {.id = "hidden_TestData"})

◆Excel最終行取得
Sub aa()
Dim lastRow As Integer
lastRow = Cells(Rows.Count, 1).End(xlUp).Row

MsgBox (lastRow & "行")

End Sub


◆
Namespace Controllers
    Public Class Test1Controller
        Inherits Controller

        ''' <summary>
        ''' Test1?id=1
        ''' </summary>
        ''' <returns></returns>
        Function Index() As ActionResult
            If Request.QueryString("id") IsNot Nothing Then
                Dim idx As String = Request.QueryString("id")
                Select Case idx
                    Case 1
                        Debug.Print("")
                    Case 2
                        Debug.Print("")
                    Case 3
                    Case Else
                        Debug.Print("")
                End Select
            End If

            TempData("param1") = "ぱらめーた１"
            Return Redirect("Todoed")
        End Function

    End Class
End Namespace

--
'Dim fruitList As New List(Of String)(New String() {"apple", "banana", "citrus"})
'
'For Each fruit As String In fruitList
'    Console.WriteLine (fruit)
'Next

Function mokuji(name As String) As String
    name1 = Trim(name)
    pos = InStr(name1, "(")
    If pos = 0 Then
        mojiku = name
        Exit Function
    End If
    a = Left(name1, pos - 1)
    b = Right(name1, Len(name1) - pos + 1)
    b = Mid(b, 2, Len(b) - 2)
    mokuji = "aaa ( " & a & ") " & b
End Function

Sub aa()

    'クラス名のセル位置
    Dim sClassNameCell As String: sClassNameCell = "b3"
    
    Dim i
    Dim ws As Worksheet
    Dim aClassName As String
    
    Row = ActiveCell.Row
    col = ActiveCell.Column
    Line = 1
    
    For i = 2 To Worksheets.Count
      Set ws = Worksheets(i)
      
      aClassName = ws.Range(sClassNameCell)
      
      a = mokuji(aClassName)
      Cells(Row, col) = a
      
      'Cells(Row, col).NumberFormatLocal = "@"
      'ActiveSheet.Hyperlinks.Add Anchor:=Cells(Row, col), Address:="", SubAddress:="'" & ws.name & "'" & "!A1", TextToDisplay:=ws.name
      
      Row = Row + 1
      
      ss = ""
      For r = 2 To 100
        b = ws.Cells(r - 1, 1)
        s = ws.Cells(r, 1)
        If s <> "" Then
            If b = "" Then
                ss = s
            Else
                ss = ss + s
            End If
        ElseIf s = "" Then
            If ss <> "" Then
                Cells(Row, col + 1) = ss
                ss = ""
                Row = Row + 1
            End If
        End If
      Next
    Next
End Sub

