The MaxLength works for inpu but not for output as discussed here: https://stackoverflow.com/questions/...gth-for-output . How can I limit the digit numbers in a textbox?
Printable View
The MaxLength works for inpu but not for output as discussed here: https://stackoverflow.com/questions/...gth-for-output . How can I limit the digit numbers in a textbox?
Hi,
ist it this your after..
regardsCode:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MeineZahl As Double
MeineZahl = 0.129456789
TextBox1.Text = MeineZahl.ToString("0.##")
MeineZahl = 2.555
TextBox2.Text = MeineZahl.ToString("0.##")
End Sub
Chris
ChrisE just put the code in a button as an example, you can use the same code in any event you like (in this case, where your calculator sets the value of the textbox).
In terms of truncating to a certain number of characters, you can do this:
Code:If TextBox1.Text.Length > 10 Then TextBox1.Text = TextBox1.Text.SubString(0,10)
No problem :)
As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).