Search code examples
vbauserform

Formatting Textbox in VBA 4 place decimal


Is there anyway that you can format a textbox format to have four decimal places at all time? I know how to do it with C# and Visual Basic using a masked textbox, but vba is a bit more challeging due to the lack of function. Any help would be greatly appreciated. Thanks

Public Sub UserForm_Initialize()
TextBox6.Text = Format(Number, "###.####")
End Sub

Solution

  • You just have the format string incorrect. It should look like this:

    Public Sub UserForm_Initialize()
        TextBox6.Text = Format(Number, "0.0000")
    End Sub