I have value in stringbuilder in richtextbox from datagridview. The value from Jan until present but the value is not as I expected. The result is :
Month : Jan
ProjectA 116
MEET 112, 96.55%
MISSED 4, 3.45%
ProjectB 4
MEET 3, 75.00%
MISSED 1, 25.00%
ProjectC 8
MEET 2, 25.00%
MISSED 6, 75.00%
etc
My expectation is :
Month : Jan
ProjectA 116
MEET 112, 96.55%
MISSED 4, 3.45%
ProjectB : 4
MEET : 2, 50.00%
MISSED : 2, 50.00%
ProjectC : 8
MEET : 3, 37.50%
MISSED : 5, 62.50%
I already check on the value in datagridview ( eg MEET / MISSED , Project ) , there is nothing wrong with that
This my syntax :
Dim DicAchievement, DicProject As New Dictionary(Of String, Integer)()
Dim cellValue As String = Nothing
Dim cellMeet As String = Nothing
Dim sb As New StringBuilder()
For i As Integer = 0 To DataGridView1.Rows.Count - 1
If Not DataGridView1.Rows(i).IsNewRow Then
cellValue = Trim(DataGridView1("Project", i).Value.ToString())
If Not DicProject.ContainsKey(cellValue) Then
DicProject.Add(cellValue, 1)
Else
DicProject(cellValue) += 1
End If
End If
Next
For i As Integer = 0 To DataGridView1.Rows.Count - 1
If Not DataGridView1.Rows(i).IsNewRow Then
cellValue = Trim(DataGridView1("Project", i).Value.ToString())
cellMeet = Trim(DataGridView1("Achievement", i).Value.ToString())
If cellMeet.Contains("MEET") Then
If Not cellMeet = vbNullString Then
If Not DicAchievement1.ContainsKey(cellValue) Then
DicAchievement1.Add(cellValue, 1)
Else
DicAchievement1(cellValue) += 1
End If
End If
End If
End If
Next
sb.AppendLine("Month : " & Me.CMonth.Text & vbNewLine)
Dim lineStrings = DicProject.Zip(DicAchievement1, _
Function(m, mt) String.Format("{0} : {1}" & vbNewLine & "MEET : {2}, {3}" & vbNewLine & "MISSED : {4}, {5}", _
UCase(m.Key), m.Value, mt.Value, FormatPercent((mt.Value / m.Value), 2), m.Value - mt.Value, _
FormatPercent((m.Value - mt.Value) / m.Value, 2), mt.Value))
For Each ls In lineStrings
sb.AppendLine(ls & vbNewLine)
Next
RichTextBox2.Text = sb.ToString
whether there is something wrong with my syntax ?
Please help......