I get the value that doesn't add up correct.
I have 2 textboxes where I enter numbers, I then calculate them and present
them as a reslut in a 3rd
textbox, however when the result is calculated it won't calculate the
correct value.
For instance when the value is 75,25 the code interprets it as 75.
The code:
lblSumma2.Text = Val(lblSumma2.Text) + ((txtAntal.Text) * myMinutNetto) +
myFastNetto
The problem is the val(lblsumma2.text), it skips the decimals, how can I
change this to use the actual number?
(lblSumma2.text will show the correct value, the problem is just when using
the val()-option)
Regards
/Drygast 4 8104
* "Drygast" <dr*****@hotmail.com> scripsit: I have 2 textboxes where I enter numbers, I then calculate them and present them as a reslut in a 3rd textbox, however when the result is calculated it won't calculate the correct value. For instance when the value is 75,25 the code interprets it as 75.
The code: lblSumma2.Text = Val(lblSumma2.Text) + ((txtAntal.Text) * myMinutNetto) + myFastNetto
The problem is the val(lblsumma2.text), it skips the decimals, how can I change this to use the actual number? (lblSumma2.text will show the correct value, the problem is just when using the val()-option)
<msdn>
Note The Val function recognizes only the period (.) as a valid decimal separator. When different decimal separators are used, as in international applications, use CDbl or CInt instead to convert a string to a number.
</msdn>
You can use 'Double.Parse' to parse the value of the string.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Lightning fast repsonse!
Thanks I'll try yout suggestion.
I also tried a "short-cut" using
val(lblSumma2.text.Replace(",", "."))
and that worked for me.
Regards
/Drygast
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bm************@ID-208219.news.uni-berlin.de... * "Drygast" <dr*****@hotmail.com> scripsit: I have 2 textboxes where I enter numbers, I then calculate them and
present them as a reslut in a 3rd textbox, however when the result is calculated it won't calculate the correct value. For instance when the value is 75,25 the code interprets it as 75.
The code: lblSumma2.Text = Val(lblSumma2.Text) + ((txtAntal.Text) * myMinutNetto)
+ myFastNetto
The problem is the val(lblsumma2.text), it skips the decimals, how can I change this to use the actual number? (lblSumma2.text will show the correct value, the problem is just when
using the val()-option) <msdn> Note The Val function recognizes only the period (.) as a valid decimal
separator. When different decimal separators are used, as in international
applications, use CDbl or CInt instead to convert a string to a number. </msdn>
You can use 'Double.Parse' to parse the value of the string.
-- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet>
* "Drygast" <dr*****@hotmail.com> scripsit: Lightning fast repsonse!
Thanks I'll try yout suggestion.
I also tried a "short-cut" using val(lblSumma2.text.Replace(",", "."))
and that worked for me.
Notice that this will not work on every systems as expected because
different languages/cultures use different characters as decimal comma.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
"Drygast" <dr*****@hotmail.com> schrieb I get the value that doesn't add up correct.
I have 2 textboxes where I enter numbers, I then calculate them and present them as a reslut in a 3rd textbox, however when the result is calculated it won't calculate the correct value. For instance when the value is 75,25 the code interprets it as 75.
The code: lblSumma2.Text = Val(lblSumma2.Text) + ((txtAntal.Text) * myMinutNetto) + myFastNetto
The problem is the val(lblsumma2.text), it skips the decimals, how can I change this to use the actual number?
Don't use Val. It expects the "." as decimal separator. Use Decimal.Parse,
Double.Parse, CSng, CDec, CDbl, ...
(lblSumma2.text will show the correct value, the problem is just when using the val()-option)
--
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul M. Frazier, Ph.D. |
last post by:
I am writing a user information update page and I populate the form on
Page_Load with the current values of the user's name, etc. When I
change the text in one of the textbox controls (e.g.,...
|
by: Steve S |
last post by:
Heres what I want to do...User types into a texbox, clicks a button, the
button saves that text to a file. The problem is that when I click the
submit button, any changes made to the textbox are...
|
by: Martin |
last post by:
Dear Group
Sorry for bothering you again but I need expert advice on this.
I have placed a HTML textbox on my aspx form and converted it to run
as a server control. At some point in my code I...
|
by: David Kyle |
last post by:
Hello there,
I'm having some problems setting the TextBox.Text Property in my code and
having it returned to the client in the source when the
TextBox.TextMode="Password".
I know this is...
|
by: Ruben |
last post by:
I have this code, I need see in textbox.text all my information, how I do that
Function Consultas(ByVal usuario As String) As System.Data.DataSet
Dim connectionString As String =...
| |
by: hans.bonefaas |
last post by:
Hi all,
I hope someone can help me with the following problem in ASP.net.
I want to edit the information for a record in a database (MS Access).
On the page I placed several textboxes and...
|
by: Keith |
last post by:
I've been reading and looking on the internet - but I just can't fin
this. Perhaps I'm approaching this the wrong way - code-wise
I'm attempting to learn how "things" work in VBNET by creating...
|
by: d.steininger |
last post by:
Hi there!
Is there a way to bind a Textbox.Text to a ScrollBar.Value (not the
Textbox-own Scrollbar) and vice versa?
The Problem:
I have to deal with two controls. The Textbox should accept...
|
by: mervyn |
last post by:
Hi There,
I am very new to .NET and VB so this may be a really simple thing to solve but here is my issue
I have a a textbox with a value in it. I know what the length of the text in the text...
|
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: 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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |