Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > 2 decimal places in textbox


Reply
 
Thread Tools Display Modes
  #1  
Old 11-26-2001, 09:32 PM
deepika
Guest
 
Posts: n/a
Default 2 decimal places in textbox


I have got 2 textboxes. The summation of the numbers in the 2 textboxes should go in third textbox. I am doing it in the following way:
text3.text = cdbl(text1.text)+cdbl(text2.text).

What I want is the number in third text box should not exceed 2 decimal places. How to do it??? Help!!!!
Reply With Quote
  #2  
Old 11-26-2001, 09:41 PM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Default Re: 2 decimal places in textbox

text3.text = Round(cdbl(text1.text)+cdbl(text2.text),2)
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #3  
Old 11-26-2001, 09:41 PM
Spike's Avatar
Spike Spike is offline
Senior Contributor
 
Join Date: Jan 2000
Location: Oregon
Posts: 1,008
Default Re: 2 decimal places in textbox

use the formatnumber method...

<pre>text3.text = formatnumber((<font color=blue>CDbl</font color=blue>(text1.text) + <font color=blue>CDbl</font color=blue>(text2.text)), 2)
</pre>


This will make it so there are 2 numbers after the decimal place

Spike
<font color=red>As I close my eyes, I feel it all slipping away!</font color=red>
Slipknot-Left Behind
__________________
Spike
-Sound clip of the week-
The ashes of the dead will be a sign | The time approaches
Killswitch Engage - Numbered Days
Reply With Quote
  #4  
Old 11-26-2001, 11:57 PM
karimahta karimahta is offline
Senior Contributor

* Guru *
 
Join Date: Mar 2000
Location: Christchurch, New Zealand
Posts: 470
Cool Re: 2 decimal places in textbox

Man, I did not even know that function existed!
You learn something new everyday.

Good Man


Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->