Have the following code which creates a table of all the images in a folder.

VB:

Sub Page_Load(sender as Object, e as EventArgs)
    If Not Page.IsPostBack then
      Dim dirInfo as New DirectoryInfo(Server.MapPath("/images"))
      articleList.DataSource = dirInfo.GetFiles("*.jpg")
      articleList.DataBind()
    End If
  End Sub

Body:

<asp:DataGrid runat="server" id="articleList" AutoGenerateColumns="False" ShowHeader="false">
    <Columns>
      <asp:BoundColumn DataField="Name" />
    </Columns>
  </asp:DataGrid>

The results look something like this:

aa_01.jpg
aa_02.jpg
aa_03.jpg
bb_01.jpg
bb_02.jpg
cc_01.jpg
cc_02.jpg
cc_03.jpg
cc_04.jpg
...

What I want to do now is group all these by the first two characters and get the total number for each and insert them into individual strings. So for the above example it would be something like:

Dim aa As String = 3
Dim bb As String = 2
Dim cc As String = 4

Any ideas how?

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top