i meet 2 problems now.
the 1st problem is ,i have a sortedList, i need to change the value into percentage.
my 2nd problem is after change to percentage.
when i key in minimum support, if the value which is not fulfill the minimum support, then will ignore it.
* total trasaction is 20=contentBox
my sortedLIst:
1: 11
2: 14
4: 5
3: 13
6: 3
5: 6
now i can change the value to percentage.the code are shown below.
but the problem is , it just can show value only, i want the output is like this:
1: 55
2: 70
4: 25
3: 65
6: 15
5: 30
double v2;
richTextBox13.Clear();
foreach (String sorting2 in sortList1.Keys)
{
if (!(sortList11.ContainsKey(sorting2)))
{
sortList1.TryGetValue(sorting2, out v2);
sortList11.Add(sorting2, v2);
double Count1 = (double)sortList11[sorting2];
sortList11[sorting2] = (v2 / ContentBox.Lines.Length)*100;
}
richTextBox13.AppendText(sortList11[sorting2].ToString() + "\n");
}
double[] store = new double[richTextBox13.Lines.Length];
int al = 0;
foreach (double abv in sortList11.Values)
{
store[al] = abv;
al++;
}
string min_supp = textBox9.Text;
double min = Double.Parse(min_supp);
textBox4.Text = textBox9.Text;
string output = "";
for (int prune = 0; prune < richTextBox13.Lines.Length; prune++)
{
if (store[prune] >= min)
{
output += store[prune] + "\n";
}
richTextBox14.Clear();
richTextBox14.AppendText(output );
}
explaination above are my 1st problem.
for my 2nd problem,
if i get my expected output,
then if i key in minimum support like 40%, if nto fulfill 40, it will ignore.
My expected output is :
1: 55
2: 70
3: 65
hope can help me..
Loading
VulpesPosted Apr 10, 2011, 2:24 PM
Are you putting '40' in the textbox or '40%'? The latter though would give an exception.
You'll have to try and debug it concentrating on this part of the code:
for (int prune = 0; prune < richTextBox13.Lines.Length; prune++)
{
string[] items = richTextBox13.Lines[prune].Split(':');
string key = items[0];
double value = Double.Parse(items[1]);
if (value >= min)
{
output += key + ": " + value.ToString() + "\n"; // put a breakpoint here
}
}
I'd put a breakpoint on the line indicated and check what 'key' and 'value' are each time through the loop.
VulpesPosted Apr 11, 2011, 8:48 AM
y sPosted Apr 11, 2011, 12:15 AM
1: 55
2: 70
3: 65
may i know how to store it into sortedList?
y sPosted Apr 10, 2011, 12:35 PM
My expected output is :
1: 55
2: 70
3: 65
still cannot come out with this output.
y sPosted Apr 10, 2011, 12:33 PM
richTextBox13.Clear();
foreach (String sorting2 in sortList1.Keys)
{
if (!(sortList11.ContainsKey(sorting2)))
{
sortList1.TryGetValue(sorting2, out v2);
sortList11.Add(sorting2, v2);
double Count1 = (double)sortList11[sorting2];
sortList11[sorting2] = (v2 / ContentBox.Lines.Length) * 100;
}
richTextBox13.AppendText(sorting2 + ": " + sortList11[sorting2].ToString() + "\n");
}
string min_supp = textBox9.Text;
double min = Double.Parse(min_supp);
textBox4.Text = textBox9.Text;
string output = "";
for (int prune = 0; prune < richTextBox13.Lines.Length; prune++)
{
string[] items = richTextBox13.Lines[prune].Split(':');
string key = items[0];
double value = Double.Parse(items[1]);
if (value >= min)
{
output += key + ": " + value.ToString() + "\n";
}
}
richTextBox14.Clear();
richTextBox14.AppendText(output);
i have did any mistake with it?
VulpesPosted Apr 10, 2011, 12:19 PM
double value = Double.Parse(items[1]);
y sPosted Apr 10, 2011, 12:17 PM
double value = Double.Parse(items[i);
the item[i] is what?
i change it to item[0]; but no output also .
my" min" values does not key in too high.
VulpesPosted Apr 10, 2011, 12:01 PM
However, as long as you haven't cleared the richTextBox13 again, then I'd expect this to work.
for (int prune = 0; prune < richTextBox13.Lines.Length; prune++)
{
string[] items = richTextBox13.Lines[prune].Split(':');
string key = items[0];
double value = Double.Parse(items[1]); // CORRECTED
if (value >= min)
{
output += key + ": " + value.ToString() + "\n";
}
}
richTextBox14.Clear();
richTextBox14.AppendText(output);
If you're seeing nothing, then perhaps your 'min' value is set so high that it's filtering every line out?
y sPosted Apr 10, 2011, 11:52 AM
if i use this line
string value = Double.Parse(items[0]);
then got error, therefor i change it to double value = Double.Parse(items[0]);
after i change it, can run the program , but nothing come out.
VulpesPosted Apr 10, 2011, 11:21 AM