Can anyone help me to display the output in MessageBox for the
following program result?
--------------------------------------------------------------------------------------------------------------------
using System;
using System.Collecti ons.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.WriteLi ne("Year\tAmoun t On Deposit\tIntere st");
for (int year = 1; year <= 100; year++)
{
interest += a * r;
a = p + a * (1 + r);
Console.WriteLi ne("{0}\t{1:C}\ t\t{2:C}", year, a,
interest);
}
}
} // class A2
} 3 10115
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.
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.
Uzytkownik "Amanda" <am**********@y ahoo.comnapisal w wiadomosci
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
>
Michael A. Covington wrote:
>I think what you want is:
MessageBox.Sho w(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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 a handler. The
handler portion seems to fail indicating that my
parameters are invalid. I am getting an error code 126
when i try to register the handler and 28 when i register
for event notification. Any ideas as to what the deal is?
I am...
|
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 Basic .Net
application.
I have researched MSDN for help and found the example article 321900 (see
below) and set up a test and everything works fine when I use SQL Server 2000
but when I modify the code and use data from Access 2000 using an...
|
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 but the text "Disposed!"
does not appear on the MessageBox. I can get the text to display if I add
aditional MessageBox switch options. Is there a reference or something I'm
missing so I don't have to add these options everytime I use the...
|
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 like the solution used by MessageBox, where you call the static
Show() method, which
returns a DialogResult value...
|
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 AddPathAndCallCompactDB(string dbFolder, string systemDB,
string UserID, string Pwd, string dbFileName)
{
FileInfo dbFileInfo = new FileInfo(dbFolder + dbFileName);
this.lblDatabase.Text = dbFileInfo.Name;
if (dbFileInfo.Exists)
| |
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 columns, "scode" and "sname", as 1 column
(if not possible then 2 columns will be fine) in the listbox. Can the
listbox display 2 columns information from the dataset and how can I do that?
Also, I set the property of the listbox to selectionmode...
|
by: A.A. Fussy |
last post by:
What code would I use for displaying a message box in VB.NET
|
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 implemented using Inherits
System.Collections.Specialized.NameObjectCollectionBase and also has the
<Serializable()> flag before the class name declaration.
In the calling code, I'm successfully serializing the object to an XML file
using a...
|
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
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |