QuestionI want simple code

Posts 1–15 of 19 · Page 1 of 2
I want simple code
hi everyone

i want a code that check textbox if it is has 8 characters in it or not and if not

keep what has been written in textbox and append to it 0 until max length of the text box

something like this

Code:
If TextBox1.TextLength < TextBox1.MaxLength Then

TextBox1.Text = TextBox1.Text + i do not know what to write here :D

End If
and someone tell me how i can make my thread resolved after 1 day ? i cant edit me old threads

thanks in advance
So you want the textbox text to be a max length of 8 and if it goes over, remove the trailing chars?

I don't understand you sunshine... @Ell0ll
Quote Originally Posted by Pingo View Post
So you want the textbox text to be a max length of 8 and if it goes over, remove the trailing chars?

I don't understand you sunshine... @Ell0ll
firstly > thanks for reply

2nd my text box max length is 8 when i click the button > check the text box

if it has less than max length lets say 5 characters

then fill the last 3 character with 0
@Ell0ll
You mean something like this
Code:
    Sub TestIt(ByRef TB As TextBox)
        For i = TB.Text.Length To TB.MaxLength - 1
            TB.Text += "0"
        Next
    End Sub
And you said something about using it on a button
Code:
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        TestIt(TextBox1)
    End Sub
Might be a better way but this was the first thing that came to mind.
Quote Originally Posted by Pingo View Post
@Ell0ll
You mean something like this
Code:
    Sub TestIt(ByRef TB As TextBox)
        For i = TB.Text.Length To TB.MaxLength - 1
            TB.Text += "0"
        Next
    End Sub
And you said something about using it on a button
Code:
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        TestIt(TextBox1)
    End Sub
Might be a better way but this was the first thing that came to mind.
thanks it is working

what about making my thread resolved i made old threads before but i cant edit it
Quote Originally Posted by Pingo View Post
@Ell0ll
You mean something like this
Code:
    Sub TestIt(ByRef TB As TextBox)
        For i = TB.Text.Length To TB.MaxLength - 1
            TB.Text += "0"
        Next
    End Sub
And you said something about using it on a button
Code:
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        TestIt(TextBox1)
    End Sub
Might be a better way but this was the first thing that came to mind.
@Pingo please can you make another code that append 0 at the first of textbox

if any one can do that it will be good

thanks in advance
@Pingo / OP

I think there is a string function for this... I found it when writing a "pad left w/ 0's" function for my assembler project.

.PadLeft(mazSize, "0") '// '0' is the char to be added on, maxsize = max string length
.PadRight(maxSize, "0")

Probably the same efficiency. : )
Quote Originally Posted by abuckau907 View Post
@Pingo / OP

I think there is a string function for this... I found it when writing a "pad left w/ 0's" function for my assembler project.

.PadLeft(mazSize, "0") '// '0' is the char to be added on, maxsize = max string length
.PadRight(maxSize, "0")

Probably the same efficiency. : )
please write simple code
No idea, i don't open many threads.

Maybe @Psychotic can mark this thread as resolved.
Quote Originally Posted by Pingo View Post
No idea, i don't open many threads.

Maybe @Psychotic can mark this thread as resolved.
thanks
Code:
If TextBox1.TextLength < TextBox1.MaxLength Then

TextBox1.Text = TextBox1.PadRight(TextBox1.MaxLength, "0")

End If
I thought? Might open the ide and check..

edit: Did*
Quote Originally Posted by abuckau907 View Post
Code:
If TextBox1.TextLength < TextBox1.MaxLength Then

TextBox1.Text = TextBox1.PadRight(TextBox1.MaxLength, "0")

End If
I thought? Might open the ide and check..
Not working

Works for me.

I assumed your text box is named "TextBox1" ... mine is txtOutput ; )

---------- Post added at 07:22 PM ---------- Previous post was at 07:20 PM ----------


use .PadRight()
use .PadRight() ?
Quote Originally Posted by abuckau907 View Post


---------- Post added at 07:20 PM ---------- Previous post was at 07:16 PM ----------


Works for me.

I assumed your text box is named "TextBox1" ... mine is txtOutput ; )

---------- Post added at 07:22 PM ---------- Previous post was at 07:20 PM ----------


use .PadRight()
use .PadRight()
use .PadRight()
i thought it will work but still not working it is even not give me the msg box i do not know why

i made a new button and wrote same as you and nothing happened no msg box appeared
edit: there is a bigger problem. I do not know.
Posts 1–15 of 19 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us