PDA

View Full Version : Solved: Returning a value into a textbox without Decimal Places Shown



Rlb53
01-29-2012, 06:59 PM
1: I am returning VALUE into a textbox within a Userform.

The range in which the VALUE is acquired has been formatted to display as a WHOLE NUMBER without decimal places.

The VALUE returned into the textbox is displayed as the actual number which contains numerous decimal points.

I wish for the VALUE returned to be displayed as a WHOLE number without decimal places.

How may this be accomplished?

2: What may be added to the "Userform.show" command to call for the VALUES to be displayed within the textbox when the Userform is opened?

Thank you for your assistance.

frank_m
01-29-2012, 07:32 PM
Does this help?
UserForm1.TextBox1.Value = Format(Range("A1").Value, "0")
UserForm1.Show

Rlb53
01-29-2012, 08:08 PM
Thank you Frank !

I'd have responded quicker but the Server has been too busy to get into.

But... Removing the unnecessary decimal places has been accomplished.

Succeeding in filling the Textbox information when the Userform.show command is executed has not.

I'm still working on that portion of the task.

Thanks again !

frank_m
01-29-2012, 08:31 PM
Where does the value come from? A cell?

Perhaps something like.
Private Sub UserForm_Initialize()
Me.TextBox1.Value = Format(Sheet1.Range("A1").Value, "0")
End Sub

Rlb53
01-29-2012, 08:34 PM
Frank,

I found a solution to activate the userform and insert the values within the textbox's. I created a sub-routine - "userform_activate" which includes a messagebox (which is needed). Upon execution / acknowledgement of the messagebox, the values are shown within the textbox as desired.

Private Sub UserForm_activate()
MsgBox "Replace the Proposed Component Quantities with the Actual Quantities Used."
Me.1.Value = Format(Range("b11").Value, 0)
Me.2.Value = Round(Range("B12").Value, 0)
Me.3.Value = Round(Range("B13").Value, 0)
Me.4.Value = Round(Range("B14").Value, 0)
Me.5.Value = Round(Range("B15").Value, 0)
Me.6.Value = Round(Range("B16").Value, 0)
Me.7.Value = Round(Range("F18").Value, 0)

End Sub

Thank you for responding.