18 1248
On Mar 12, 2:41*am, "enrico via DotNetMonster.com" <u41845@uwewrote:
how can i do this:
textbox1 + textbox2 = textbox3
(the two fields are given and the last field is automatically calculated.)
--
Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200803/1
You mean? :
textbox3.text = textbox1.text + textbox2.text
But be careful textbox holds strings, that your input must consist of
numbers not to get an exception.
"kimiraikkonen" wrote:
On Mar 12, 2:41 am, "enrico via DotNetMonster.com" <u41845@uwewrote:
how can i do this:
textbox1 + textbox2 = textbox3
(the two fields are given and the last field is automatically calculated.)
--
Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200803/1
You mean? :
textbox3.text = textbox1.text + textbox2.text
But be careful textbox holds strings, that your input must consist of
numbers not to get an exception.
Actually, this concatenates the strings. If Textbox1.text = "4" and
textbox2.text = "5" then textbox3.text will be set to "45". If Textbox1.text
= "Blue" and textbox2.text = "green", then textbox3.text will be set to
"Bluegreen".
On Mar 12, 3:42*am, "enrico via DotNetMonster.com" <u41845@uwewrote:
what if your calculating numbers represented by an integer or double and not
string?
--
Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200803/1
Enrico,
Just type that code should work fine as far as you enter valid numbers
into textboxes:
Here you can change integer to double or long whatever variable you
wish to use depends on your variable's scale:
Dim firstval As Integer = textbox1.text
Dim secondval As Integer = textbox2.text
Dim result As Integer = textbox3.text
result = firstval + secondval
Hope this helps...
"enrico via DotNetMonster.com" <u41845@uweschrieb:
how can i do this:
textbox1 + textbox2 = textbox3
(the two fields are given and the last field is automatically calculated.)
In addition to the other replies, take a look at 'Integer.TryParse' and
'Double.TryParse'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
"kimiraikkonen" wrote:
On Mar 12, 3:42 am, "enrico via DotNetMonster.com" <u41845@uwewrote:
what if your calculating numbers represented by an integer or double and not
string?
--
Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200803/1
Enrico,
Just type that code should work fine as far as you enter valid numbers
into textboxes:
Here you can change integer to double or long whatever variable you
wish to use depends on your variable's scale:
Dim firstval As Integer = textbox1.text
Dim secondval As Integer = textbox2.text
Dim result As Integer = textbox3.text
result = firstval + secondval
Hope this helps...
Well, with strict on, it does not compile. Without that, it is not working
for me. I believe you will need to use Integer.TryParse(textbox1.text), etc,
as Herfreid suggested.
"Family Tree Mike" wrote:
>
"kimiraikkonen" wrote:
On Mar 12, 3:42 am, "enrico via DotNetMonster.com" <u41845@uwewrote:
what if your calculating numbers represented by an integer or double and not
string?
>
--
Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200803/1
Enrico,
Just type that code should work fine as far as you enter valid numbers
into textboxes:
Here you can change integer to double or long whatever variable you
wish to use depends on your variable's scale:
Dim firstval As Integer = textbox1.text
Dim secondval As Integer = textbox2.text
Dim result As Integer = textbox3.text
result = firstval + secondval
Hope this helps...
Well, with strict on, it does not compile. Without that, it is not working
for me. I believe you will need to use Integer.TryParse(textbox1.text), etc,
as Herfreid suggested.
Sorry Kimi, my bad... I missed a line. It does work with option strict off.
Enrico,
As you know that it are integers
if Isnumeric(textbox2) and also Isnumeric(textbox1) then
textbox3.text = (CInt(textbox2) + (Cint(textbox3)).ToString
End if
Be aware that as soon as you use decimals it has to be CDouble or CDecimal
Cor
>
Herfried,
>
In addition to the other replies, take a look at 'Integer.TryParse' and
'Double.TryParse'.
In my idea not very much VB program language likewise.
However my idea as I wrote.
Cor
On Mar 12, 4:54*am, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
"Family Tree Mike" wrote:
"kimiraikkonen" wrote:
On Mar 12, 3:42 am, "enrico via DotNetMonster.com" <u41845@uwewrote:
what if your calculating numbers represented by an integer or doubleand not
string?
--
Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200803/1
Enrico,
Just type that code should work fine as far as you enter valid numbers
into textboxes:
Here you can change integer to double or long whatever variable you
wish to use depends on your variable's scale:
Dim firstval As Integer = textbox1.text
Dim secondval As Integer = textbox2.text
Dim result As Integer = textbox3.text
result = firstval + secondval
Hope this helps...
Well, with strict on, it does not compile. *Without that, it is not working
for me. *I believe you will need to use Integer.TryParse(textbox1.text), etc,
as Herfreid suggested.
Sorry Kimi, my bad... * I missed a line. *It does work with option strict off.- Hide quoted text -
- Show quoted text -
Yeah, i didn't use any option strict mode to get it work.
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
As you know that it are integers
if Isnumeric(textbox2) and also Isnumeric(textbox1) then
textbox3.text = (CInt(textbox2) + (Cint(textbox3)).ToString
End if
What's the 'IsNumeric' check for? 'IsNumeric' will return 'True' for values
which 'CInt' cannot handle and which maybe cannot be represented in the
'Integer' type.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
"enrico via DotNetMonster.com" <u41845@uweschrieb:
where will i insert that "...parse" code in my procedure? i'm new to this
language, haven't gone a long way yet...
\\\
Dim a, b As Integer
If Not Integer.TryParse(Me.TextBox1.Text, a) Then
' Set error provider or show an error message.
Return
End If
If Not Integer.TryParse(Me.TextBox2.Text, b) Then
' Set error provider or show an error message.
Return
End If
Me.TextBox3.Text = (a + b).ToString()
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Herfried,
It checks for most things normal users enter, even exponents.
I thought I had set in my messages, that if there would be decimals to use
CDouble, I used Cint to show how simple it was.
Cor
"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:uZ**************@TK2MSFTNGP04.phx.gbl...
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
>As you know that it are integers
if Isnumeric(textbox2) and also Isnumeric(textbox1) then textbox3.text = (CInt(textbox2) + (Cint(textbox3)).ToString End if
What's the 'IsNumeric' check for? 'IsNumeric' will return 'True' for
values which 'CInt' cannot handle and which maybe cannot be represented in
the 'Integer' type.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
It checks for most things normal users enter, even exponents.
I thought I had set in my messages, that if there would be decimals to use
CDouble, I used Cint to show how simple it was.
Well, all I wanted to say is that your solution can result in runtime errors
depending on what the user enters.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:ul**************@TK2MSFTNGP06.phx.gbl...
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
>It checks for most things normal users enter, even exponents.
I thought I had set in my messages, that if there would be decimals to use CDouble, I used Cint to show how simple it was.
Well, all I wanted to say is that your solution can result in runtime
errors depending on what the user enters.
All I wanted to show was that you were leaving your old habbit to use
forever Microsoft.VisualBasic commands while there were better System.Net
ones. (Which is not forever, don't understand that wrong).
Cor
"enrico via DotNetMonster.com" <u41845@uwewrote in message
news:8105406ea25cf@uwe...
how can i do this:
textbox1 + textbox2 = textbox3
(the two fields are given and the last field is automatically calculated.)
--
Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/For...b-net/200803/1
As has been suggested to you elsewhere, turn on Options Strict and Explicit,
then use the generated syntax errors to help you get rid of the bad code.
<Ju********@home.netschrieb:
First, make sure they are both numeric.
if isnumeric(textbox1.text) and isnumeric(textbox2.text) then
'Then simply add the values
textbox3.text = val(textbox1.text) + val(textbox2.text)
'Val' is not culture-sensitive, which means that it recognizes only the
period (".") as a valid decimal separator. In Germany, for example, "," is
used as decimal separator.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stefanos |
last post by:
Hi everybody,
I need some help on calculated values in my database design.
I'm creating an accounting / business management application with the
usual modules like A/R, A/P, Inventory, etc.
...
|
by: SJH |
last post by:
I have been given an older database and asked to make upgrades and what not.
One interesting thing I have come across with the database is that it was at
one time set up so one of the tables would...
|
by: Henry |
last post by:
Hi
Is there any good ideas how to update form vb code always after some values
are changed / added by vb (not user).
I have some code behind subforms vb and there are calculations behind...
|
by: Jeremy Weiss |
last post by:
I've got a temp table that contains the fields: amountowed, amountpaid, and
balanced. I've got a form that shows this information and I've set it up so
that when the amountpaid field is changed it...
|
by: douh |
last post by:
I know that this is not the way, however I need to save certian
calculated values so that they do not change over time, ie. new tax
rates etc. This is for an invoice header and invoice subform. I...
|
by: tconway |
last post by:
I have an Access program that displays Customer data into a form and
OrderID data into a subform. The totals in the Subform are based on
calculated fields, i.e. the Total Amount field Calculates...
|
by: James Hallam |
last post by:
I have read through all the past topics and couldn't find what I was
after so...
I am looking to store some calculated values (don't flame just yet,
just read on!). I have an piece of code...
|
by: kelley.l.turner |
last post by:
Hi all,
I am very new to MS Access so please bear with me! I have created a
simple calculated field in my data entry form, yet when I view my data
table or try to generate a report based on...
|
by: jcf378 |
last post by:
hi all.
I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ).
However, when I click "Filter by...
|
by: NatronA111 |
last post by:
I am having a problem with calculated fields (...the most important one in the database!) in an MS Access query that pulls info from one table and a few other calculated fields stored in other...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |