473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to display this using MessageBox.Show method

Can anyone help me to display the output in MessageBox for the
following program result?
--------------------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;

namespace A2_CISP40506F
{
class A2
{

static void Main(string[] args)
{
double p = 1000;
double r = .05, interest = 0;
double a = 0;
Console.WriteLine("Year\tAmount On Deposit\tInterest");
for (int year = 1; year <= 100; year++)
{
interest += a * r;
a = p + a * (1 + r);
Console.WriteLine("{0}\t{1:C}\t\t{2:C}", year, a,
interest);

}
}
} // class A2
}

Oct 8 '06 #1
3 10098
I think what you want is:

MessageBox.Show(String.Format("{0}\t{1:C}\t\t{2:C} ", year, a, interest));

In general, String.Format does the same kind of formatting as WriteLine, but
the result is returned as a string (which you can then output any way you
want) rather than being written on the console.
Oct 8 '06 #2

Michael A. Covington wrote:
I think what you want is:

MessageBox.Show(String.Format("{0}\t{1:C}\t\t{2:C} ", year, a, interest));
Yes, I couldn't use MessageBox.show because I cteated the project as
console. I fixed that.

And, I do not want the title of messagebox repeated. So I concatenated
the string and then call MessageBox.Show outside the for loop.

>
In general, String.Format does the same kind of formatting as WriteLine, but
the result is returned as a string (which you can then output any way you
want) rather than being written on the console.
Oct 8 '06 #3

Uzytkownik "Amanda" <am**********@yahoo.comnapisal w wiadomosci
news:11**********************@b28g2000cwb.googlegr oups.com...
>
Michael A. Covington wrote:
>I think what you want is:

MessageBox.Show(String.Format("{0}\t{1:C}\t\t{2:C }", year, a, interest));

Yes, I couldn't use MessageBox.show because I cteated the project as
console. I fixed that.

And, I do not want the title of messagebox repeated. So I concatenated
the string and then call MessageBox.Show outside the for loop.

>>
In general, String.Format does the same kind of formatting as WriteLine,
but
the result is returned as a string (which you can then output any way you
want) rather than being written on the console.
Try add using System.Windows.Forms it help

Forrest
Oct 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with...
9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
1
by: Kevin R | last post by:
I'm running the HelloWorldForm example from Microsoft to learn how to use ..net. I'm using Microsoft Visual Studio .NET 2003, 1.1 framework. I run the HelloWorldForm example. The example runs...
8
by: Saso Zagoranski | last post by:
Hi! I'm trying to make my own MessageBox... What I would like to know is, how the MessageBox class is implemented? I could have something like: new MyMessageBox().ShowDialog(); but I would...
7
by: jez123456 | last post by:
Hi, I have the following method where I need to display which database is being processed, however, the label lblDatabase dosn't seem to work until the end. private void...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
14
by: A.A. Fussy | last post by:
What code would I use for displaying a message box in VB.NET
2
by: Phillip Galey | last post by:
I have an object called Place which contains only string properties and has the <Serializable()> flag before the class name declaration. I also have a collection object called Places, which is...
14
by: santoshkakani | last post by:
Hi friends i can any one help me merging 2 random tables into one and displaying in gridview for example table 1 Sid SName Dno and table 2 Dno Dname Daddress
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.