Groups | Blog | Home
all groups > vj# > march 2006 >

vj# : Displaying a value stored in a variable


ByTe
3/6/2006 3:35:07 PM

Hi
I am just starting to learn how to use microsoft visual j#,
and I wonder if anyone could help me with this problem, I am
trying to display a number stored in a varible into a message
Box.show but I keep getting the Error below:

Error 1 Cannot find method 'Show(int)' in
'System.Windows.Forms.MessageBox' C:\Documents and Settings\Keith\Local
Settings\Application Data\Temporary
Projects\WindowsApplication1\Form1.jsl 84 3 WindowsApplication1


The code I am writing is:


private void button1_Click(Object sender, System.EventArgs e)
{
int x = 6;
x = 6;
MessageBox.Show(x);

}
}



Could someone please help me with this?


Thanks


Keith



--
ByTe
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
Homer J Simpson
3/8/2006 12:00:00 AM

[quoted text, click to view]

I'd expect

int x;
x = 6;
MessageBox.Show(String.Concat("X=", System.Convert.ToString(x)));

but I could be wrong.


Lars-Inge Tønnessen (VJ# MVP)
3/19/2006 6:19:50 PM

int x = 6;
// Example 1
System.Windows.Forms.MessageBox.Show("" + x);

// Example 2
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(x);
System.Windows.Forms.MessageBox.Show(sb.toString());


Regards,
Lars-Inge Tønnessen

AddThis Social Bookmark Button