From: Gabe on
I went in and formatted a cell to: 0;"0";0 so that all negative numbers will
be converted to zero. I have a textbox on a userform that I need to do the
same thing. What code would I use? I tried this but it doesn't work:

txtRemain.Value = Format(txtRemain.Value, "#,#00;""0""")

Any help would be greatly appriciated.

Thanks,
~Gabe


From: JLGWhiz on
This worked for me:

Sub gh()
Sheets(1).TextBox1.Text = 123.751
MsgBox "OK"
Sheets(1).TextBox1.Text = _
Format(Sheet1.TextBox1.Text, "#,##0.00")
End Sub


"Gabe" <Gabe(a)discussions.microsoft.com> wrote in message
news:0FA5E95F-1BDB-4F0A-B606-4E0D1B7DB7DA(a)microsoft.com...
>I went in and formatted a cell to: 0;"0";0 so that all negative numbers
>will
> be converted to zero. I have a textbox on a userform that I need to do the
> same thing. What code would I use? I tried this but it doesn't work:
>
> txtRemain.Value = Format(txtRemain.Value, "#,#00;""0""")
>
> Any help would be greatly appriciated.
>
> Thanks,
> ~Gabe
>
>


From: JLGWhiz on
Disregard, I misread the posting.


"JLGWhiz" <JLGWhiz(a)cfl.rr.com> wrote in message
news:uCzF5Sv8KHA.4600(a)TK2MSFTNGP02.phx.gbl...
> This worked for me:
>
> Sub gh()
> Sheets(1).TextBox1.Text = 123.751
> MsgBox "OK"
> Sheets(1).TextBox1.Text = _
> Format(Sheet1.TextBox1.Text, "#,##0.00")
> End Sub
>
>
> "Gabe" <Gabe(a)discussions.microsoft.com> wrote in message
> news:0FA5E95F-1BDB-4F0A-B606-4E0D1B7DB7DA(a)microsoft.com...
>>I went in and formatted a cell to: 0;"0";0 so that all negative numbers
>>will
>> be converted to zero. I have a textbox on a userform that I need to do
>> the
>> same thing. What code would I use? I tried this but it doesn't work:
>>
>> txtRemain.Value = Format(txtRemain.Value, "#,#00;""0""")
>>
>> Any help would be greatly appriciated.
>>
>> Thanks,
>> ~Gabe
>>
>>
>
>


From: JLGWhiz on
I think you are going to have a hard time getting the TextBox entry to
format as a number. It only deals with text. So any number formats have to
be handled either on the worksheet or in the variable container prior to
posting to the text box. Once in the text box, it is text and while it can
be formatted to look like numbers, it is not numeric, so it cannot tell if a
value is negative.


"Gabe" <Gabe(a)discussions.microsoft.com> wrote in message
news:0FA5E95F-1BDB-4F0A-B606-4E0D1B7DB7DA(a)microsoft.com...
>I went in and formatted a cell to: 0;"0";0 so that all negative numbers
>will
> be converted to zero. I have a textbox on a userform that I need to do the
> same thing. What code would I use? I tried this but it doesn't work:
>
> txtRemain.Value = Format(txtRemain.Value, "#,#00;""0""")
>
> Any help would be greatly appriciated.
>
> Thanks,
> ~Gabe
>
>


From: JLatham on
Try this in the text box's _Change event:

Private Sub txtRemain_Change()
If Val(txtRemain) < 0 Then
txtRemain= 0
End If
End Sub


"Gabe" wrote:

> I went in and formatted a cell to: 0;"0";0 so that all negative numbers will
> be converted to zero. I have a textbox on a userform that I need to do the
> same thing. What code would I use? I tried this but it doesn't work:
>
> txtRemain.Value = Format(txtRemain.Value, "#,#00;""0""")
>
> Any help would be greatly appriciated.
>
> Thanks,
> ~Gabe
>
>