By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,238 Members | 1,485 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,238 IT Pros & Developers. It's quick & easy.

Rounding down ...

P: n/a
Hi,

Totally new to programming and am using VB.net.

Question ... I have a simple form with three text boxes ... TextBox1,
TextBox2 and TextBox3. In TextBox3 I would like to return the value of
TextBox1 / TextBox2. I have got this working OK but would like the
TextBox3 value to be rounded down eg 3.1415926 or 3.9656365 to be shown
as 3.

Can someone explain how I would implement this.

Many thanks,

Rob.

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Rob Keel wrote:
Hi,

Totally new to programming and am using VB.net.

Question ... I have a simple form with three text boxes ... TextBox1,
TextBox2 and TextBox3. In TextBox3 I would like to return the value of
TextBox1 / TextBox2. I have got this working OK but would like the
TextBox3 value to be rounded down eg 3.1415926 or 3.9656365 to be shown
as 3.

Can someone explain how I would implement this.

Many thanks,

Rob.


I think you want the Math.Floor method... although it returns a double
it should display like a whole number in your text box.

[Visual Basic]
Public Shared Function Floor( _
ByVal d As Double _
) As Double
Nov 21 '05 #2

P: n/a
CT
There are several ways of doing this, depending on whether you want to save
the computed value, or simply display it.

TextBox1.Text = "23456"
TextBox2.Text = "5"
TextBox3.Text = Math.Floor(CDbl(TextBox1.Text) /
CDbl(TextBox2.Text)).ToString("#")
--
Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF
http://www.apress.com/book/bookDisplay.html?bID=105
Communities - http://community.integratedsolutions.dk

"Rob Keel" <ro*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi,

Totally new to programming and am using VB.net.

Question ... I have a simple form with three text boxes ... TextBox1,
TextBox2 and TextBox3. In TextBox3 I would like to return the value of
TextBox1 / TextBox2. I have got this working OK but would like the
TextBox3 value to be rounded down eg 3.1415926 or 3.9656365 to be shown
as 3.

Can someone explain how I would implement this.

Many thanks,

Rob.

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.