-
Jul 22nd, 2017, 04:19 AM
#1
Thread Starter
New Member
[RESOLVED] MaxLenght Help
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?
-
Jul 22nd, 2017, 05:48 AM
#2
Re: MaxLenght Help
Hi,
ist it this your after..
Code:
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
regards
Chris
-
Jul 22nd, 2017, 06:21 AM
#3
Thread Starter
New Member
Re: MaxLenght Help
Originally Posted by ChrisE
Hi,
ist it this your after..
Code:
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
regards
Chris
Thanks for your reply. I don't use button click, its dynamic. As soon as you type in numbers the calculator outputs the result. So if your result is "01234567890123456789" it should become -> "0123456789" only 10 digits.
-
Jul 22nd, 2017, 12:30 PM
#4
Re: MaxLenght Help
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)
-
Jul 22nd, 2017, 03:03 PM
#5
Thread Starter
New Member
Re: MaxLenght Help
Originally Posted by si_the_geek
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)
Works like a charm! Thanks.
-
Jul 22nd, 2017, 03:27 PM
#6
Re: MaxLenght Help
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).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|