how to perform aggregate computations such as Sum, Average, Min, and Max from txt file

Posted by Learn Vb under VB.NET on 1/24/2012 | Points: 10 | Views : 1272 | Status : [Member] | Replies : 0
i have combobox1 contain the name of the txt file that stored in c:/




Public Class Form1

Dim Lines As String()

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Lines = File.ReadAllLines("c:\" + ComboBox1.SelectedItem.ToString() + ".txt")
Dim list As New List(Of String)
Dim notcable As Boolean = False
For Each line As String In Lines
Dim SplitString As String() = line.Split(","c)
If SplitString.Length > 1 Then
If Not (list.Contains(SplitString(0))) Then
If notcable Then
list.Add(SplitString(0))
ComboBox2.Items.Add(SplitString(0))
Else
notcable = True
End If
End If
End If
Next
End Sub



2- combobox that will show the items from the txt file and the compute will be performed for the item that show in combobox2


so this what i did so far

1- to get the last date for the txt file by any sort



Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged


Dim comboText As String = ComboBox2.SelectedItem.ToString()
Dim strDate As Integer = 0
For Each line In Lines

Dim arrayForTheLine = line.Split(","c)


Try
If arrayForTheLine(1) > strDate Then
strDate = Integer.Parse(arrayForTheLine(1))
TextBox1.Text = strDate.ToString

End If
Catch
End Try
Next

End Sub


the date will be show as Integer


i explain what i need in the image below


[url=http://www.gulfup.com/show/X3559o2tsk42j][img]http://im16.gulfup.com/2012-01-25/1327448022541.gif[/img][/url]




thank you for your help

thank you for your support


Responses

(No response found.)

Login to post response