473,387 Members | 1,520 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,387 software developers and data experts.

Assigning Values

JJ
Hi All,

I am trying to assign an int value to a textbox. Of course C# doesn't
like this so is common to use Convert.toInt32 textboxs with numbers then use
Convert.toString assign the values back into the Textboxs? Like the
following:

tbEstLMPOnPeak.Text = Convert.ToString(Convert.ToInt32(tbTotNetOnPeak) -
1224);

Thanks,

JJ


Nov 15 '05 #1
4 6052
JJ
yes thats correct but you are doing the same thing that I did but in long
form.

I guess I am use to vb where it didn't matter what you put into a textbox
the conversion was autonatically done for you behind the scenes.

Why not c#, I guess is my question?

Thanks,

JJ

"Bill Priess" <no*****@nospam.com> wrote in message
news:oprt34aaoycimqky@localhost...
The easiest thing to do is use local variables... IMHO

int Calc1 = int.parse(txtBox1.Text);
int Calc2 = int.parse(txtBox2.Text);
txtBox3.Text = (Calc1 + Calc2).ToString();

HTH,

Bill Priess

On Mon, 18 Aug 2003 11:58:00 -0400, JJ <jm***@bellatlantic.net> wrote:
Hi All,

I am trying to assign an int value to a textbox. Of course C# doesn't
like this so is common to use Convert.toInt32 textboxs with numbers then
use
Convert.toString assign the values back into the Textboxs? Like the
following:

tbEstLMPOnPeak.Text = Convert.ToString(Convert.ToInt32(tbTotNetOnPeak) -
1224);

Thanks,

JJ



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Nov 15 '05 #2
JJ <jm***@bellatlantic.net> wrote:
yes thats correct but you are doing the same thing that I did but in long
form.

I guess I am use to vb where it didn't matter what you put into a textbox
the conversion was autonatically done for you behind the scenes.

Why not c#, I guess is my question?


Because C# is strongly typed - and a good job too, IMO.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #3
JJ
Ok so it is common practice to see coding as I had shown in these replys?

Thanks,
JJ

"JJ" <jm***@bellatlantic.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am trying to assign an int value to a textbox. Of course C# doesn't
like this so is common to use Convert.toInt32 textboxs with numbers then use Convert.toString assign the values back into the Textboxs? Like the
following:

tbEstLMPOnPeak.Text = Convert.ToString(Convert.ToInt32(tbTotNetOnPeak) -
1224);

Thanks,

JJ


Nov 15 '05 #4
Yes, but if you have a lot of integer text boxes I would consider deriving
your own class from TextBox with an int property (Value, for example) that
you can get/set the int value. Then just do the conversion inside that class
rather than everywhere in the client.

Or search for someone else's existing integer text box class, e.g.
http://dotnet247.com/247reference/msgs/10/52054.aspx

"JJ" <jm***@bellatlantic.net> wrote in message
news:OA*************@TK2MSFTNGP10.phx.gbl...
Ok so it is common practice to see coding as I had shown in these replys?

Thanks,
JJ

"JJ" <jm***@bellatlantic.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am trying to assign an int value to a textbox. Of course C# doesn't like this so is common to use Convert.toInt32 textboxs with numbers then

use
Convert.toString assign the values back into the Textboxs? Like the
following:

tbEstLMPOnPeak.Text = Convert.ToString(Convert.ToInt32(tbTotNetOnPeak) -
1224);

Thanks,

JJ



Nov 15 '05 #5

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

Similar topics

3
by: Ben | last post by:
Hi all, This may sound easy but I'm having trouble assigning values to array element. My problem is as follows: m = for o in m: # Here first o is 'Peter'.. I want to do something like this:...
1
by: Dave | last post by:
I am trying to create a function in SQL 2000. Im rusty on function syntax and need to also assign some variables for use within this function. Example: create function blah (@param1 int) ...
0
by: vanGogh | last post by:
I have generated classes based on an Xml schema file (xsd) using the XSD.exe tool. My goal is to: - write an application that can parse XML documents - fill objects (based on the generated...
16
by: BigMan | last post by:
How can I check if assignment of a float to a double (or vice versa) will result in loss of precision?
1
by: Jenny | last post by:
Hi, Can I create an array of tags by assigning same name to these tags? For example, I have two <p> tags with the same name t1. But document.all.b.value=document.all.t.length does not...
12
by: bollod | last post by:
Is there any benefit to declaring a variable: x = (1<<12); instead of: x = 4096; (besides the geek appeal of course ;-) )
14
by: Eric Bantock | last post by:
Very basic question I'm afraid. Once an array has been declared, is there a less tedious way of assigning values to its members than the following: myarray=8; myarray=3; myarray=4; myarray=0;...
8
by: Ricardo Sta. Rita | last post by:
Hello people, We have been dealing with for a long time now. It's a bit weird for a newcomer like us so we decided to ask the geniuses here. C# doesn't seem to be assigning values, consider...
0
by: ryoung | last post by:
I receive the following error when I attempt to assign values to a web service array. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. ...
37
by: miken32 | last post by:
In PHP, if a function returns an array it's fairly common to capture its return values like this: <?php list($foo, $bar, $baz) = some_function_that_return_an_array(); ?> In Javascript, would...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
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,...
0
jinu1996
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...

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.