Rounding down ...

  • Thread starter Thread starter Rob Keel
  • Start date Start date
R

Rob Keel

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.
 
Rob said:
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
 
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("#")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top