We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,703 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Enable Button If The Required Textbox is Not Null

how to enable my button if all the required textbox is not null

2
Contributors
4
Replies
2 Hours
Discussion Span
1 Year Ago
Last Updated
5
Views
Question
Answered
Shodow
Junior Poster
167 posts since Jan 2011
Reputation Points: 14
Solved Threads: 0
Skill Endorsements: 0

See if this helps.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each txt In New TextBox() {TextBox1, TextBox2, TextBox3} '// your TextBoxes.
            If txt.Text = "" Then Exit Sub '// skip remain code in Sub.
        Next
        Button2.Enabled = True '// enable if all TextBoxes have values.
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Button2.Enabled = False
    End Sub
codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

so you have to click button1 first to validate the textbox?

Shodow
Junior Poster
167 posts since Jan 2011
Reputation Points: 14
Solved Threads: 0
Skill Endorsements: 0

For my posted code, you do.
If you need to have it trigger when typing in TextBoxes, add the code to the TextChanged event of the TextBoxes.

Private Sub _TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged ', TextBoxETC.TextChanged
        '// validate TextBoxes code here.
    End Sub
codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

tnx

Shodow
Junior Poster
167 posts since Jan 2011
Reputation Points: 14
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by codeorder

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0727 seconds using 2.66MB