![]() |
IOBit Software
|
|
|
||||||
| Programming Place to discuss programming including HTML, Java, C++, MySQL and others. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi I am new to programminh and I am trying to display the whole list of my array into a textbox in windows form:
private void btnLoadCDR_Click(object sender, EventArgs e) { string inputString = txtInput.Text; var inputList = inputString.Split('\n'); var accountSvc = new Shared.Core.Account.AccountSvc(); foreach (string phoneNumber in inputList) { var history = accountSvc.GetCallDurationRecords(phoneNumber, DateTime.Parse("01/01/12"), DateTime.Parse("04/14/2012")); var calledType = history[0].CallType; txtOut.Text += string.Format("{0}:{1},{2},{3}", phoneNumber, history[31].CalledNumber, history[31].CallType, history[31].Cost) + Environment.NewLine; } } I can get the record of the array 31 for example but how do I get all the records all in one.? |
| Sponsored links |
|
|
|
#2
|
||||
|
||||
|
Since it's hard to tell the structure of your data from the post, I'll give it a shot.
It sounds like you need another loop, e.g. Code:
// Also don't forget to initialize txtOut.Text
txtOut.Text = string.Empty;
foreach (string phonNumber in inputList)
{
__________________
"I cannot undertake to lay my finger on that article of the Constitution which granted a right to Congress of expending, on the objects of benevolence, the money of their constituents." -- James Madison (1751-1836), Father of the Constitution for the USA, 4th US President _________________________ AMD Athlon 64 3800+ ABIT KN8 SLI 2 Gb (2x1Gb) PC 3200 Cas 2 Corsair XMS RAM 2x120Gb WD w/ 8Mb cache (RAID 0) eVGA GeForce 7900GT 256MB |
|
#3
|
|||
|
|||
|
Thanks Wyatt; The other loop solves the problem, Another question if I want to get the total of my histItem.Cost; how can I add the value of the cost for each record and display a total cost.
you think you can help me with that? |
|
#4
|
|||
|
|||
|
Here is the code: all the values are displaying fine but I need to get the sum of the cdrRecord.cost in the same txtOut.text.
Please help me. privatevoid btnLoadCDR_Click(object sender,EventArgs e) { string inputString = txtInput.Text; var inputList = inputString.Split('\n'); var accountSvc = new Shared.Core.Account.AccountSvc(); foreach (string phoneNumberin inputList) { var history = accountSvc.GetCallDurationRecords(phoneNumber,DateTime.Parse("01/01/12"),DateTime.Parse("04/14/2012")); foreach (var cdrRecordin history) { if (cdrRecord.CalledNumber == "19402383244" && cdrRecord.Cost > 0) { txtOut.Text +=string.Format("- {0},{1},{2}\r\n", cdrRecord.CalledNumber, cdrRecord.CallType, cdrRecord.Cost); } else { } } } } Thanks |
|
#5
|
||||
|
||||
|
It will be best to make another variable, something like this: (untested, but edits commented)
Code:
privatevoid btnLoadCDR_Click(object sender,EventArgs e)
{
string inputString = txtInput.Text;
var inputList = inputString.Split('\n');
var accountSvc = new Shared.Core.Account.AccountSvc();
float total;//new variable, which I'll initialize in the loop, use an appropriate name: "total" is really just a placeholder...
foreach (string phoneNumberin inputList)
{
var history = accountSvc.GetCallDurationRecords(phoneNumber,DateTime.Parse("01/01/12"),DateTime.Parse("04/14/2012"));
total=0.0;//init and reset to 0 for each history
foreach (var cdrRecordin history)
{
if (cdrRecord.CalledNumber == "19402383244" && cdrRecord.Cost > 0)
{
txtOut.Text +=string.Format("- {0},{1},{2}\r\n", cdrRecord.CalledNumber, cdrRecord.CallType, cdrRecord.Cost);
total+=cdrRecord.Cost;//accumulate the total, assuming cdrRecord.Cost is a number
}
txtOut.Text+=string.Format("- Total {0}\r\n",total);//put the total at the end
else
{
}
}
}
}
__________________
I.think(code); I.eat(code.spaghetti); |
| The Following User Says Thank You to PC-XT For This Useful Post: | ||
jcast (05-02-12) | ||
| Sponsored links |
|
|
|
#6
|
|||
|
|||
|
Hi; I need to make a new post (New question) and I cannot find where to click to create a new thread. Please let me know cause I need to ask a new question.
Thanks |
|
#7
|
|||
|
|||
|
I figured it out how to make a new post.
Thanks anyways |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows 7 Blue Screen after Windows Logo STOP: C0000135 BSOD | kuzya | Software | 6 | 01-12-12 14:27 |
| When Disabling Windows Snap in Windows 7, Loose Windows Aero Pointers Scheme? | montecarlo1987 | Software | 1 | 09-04-10 16:56 |
| Task Manager error: C:\Windows\System32\UTILDLL.dll is not a valid Windows image | boom929 | Malware Removal | 7 | 01-07-09 18:03 |
| \WINDOWS\SYSTEM32\CONFIG\SYSTEM corrupt, recovery console won't recognize windows | dep187 | Software | 30 | 08-08-06 21:51 |
| End of support for Windows 98, Windows Me, and Windows XP Service Pack 1 | NICK ADSL UK | Software | 1 | 07-12-06 05:53 |