Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 23-01-2010
Member
 
Join Date: Jan 2010
Posts: 62
Verify the content of the textbox with multiple buttons on Form

I am beginner in VB.net. I have a FORM with multiple button and one textbox. I wish that when I click on the button, we check if something has been entered in textbox. But how to check this? Should I have below code for each button? :
Code:
If textbox.text = "" Then
messageBox.show("Empty Fields")
Is there a way to do this for all buttons ?
Reply With Quote
  #2  
Old 23-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Verify the content of the textbox with multiple buttons on Form

Thank you to perform a little research on the forum, this same question comes up several times a week. Here is an example on a button
Code:
PrivateSub ManagementOfButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_1.Click, Button_1.Click, Button_2.Click, Button_3.Click, .......
Reply With Quote
  #3  
Old 23-01-2010
Member
 
Join Date: Jan 2010
Posts: 62
Re: Verify the content of the textbox with multiple buttons on Form

Another problem arose: when I click on the button, the error message, but the action when the button is even launched. Here is my function:

Code:
Private Sub ManagementOfButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click, button2.Click
        If TextBox1.Text.Length < 5 Then
            MessageBox.Show("Thank you to comment")
        End If
End Sub
Reply With Quote
  #4  
Old 23-01-2010
Member
 
Join Date: May 2008
Posts: 2,383
Re: Verify the content of the textbox with multiple buttons on Form

What action? At what point in your code? For there in your code I see too

If you talk to any code you place after your End If
Code:
If ..... Then
  MsgBox("YourMsg")
End If
If you do not want to go into "Your Action" to add an else if your
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 23-01-2010
Member
 
Join Date: Jan 2010
Posts: 62
Re: Verify the content of the textbox with multiple buttons on Form

SUB takes into account several buttons. If there is nothing in the textbox, type a message MessageBox.Show ("please save ...") but it is not the action of the start button, type EXIT, but it works not.

I cannot put the ELSE, because SUB manages several buttons

Here's the code:
Code:
Private Sub ManagementOfButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click, button2.Click
        If TextBox1.Text.Length < 5 Then
            MessageBox.Show("Thank you to comment")
        End If
End Sub
 
'button 1
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
webrowser.navigate(TextBox1.Text)
End Sub
 
'button 2
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
webrowser.navigate(TextBox1.Text)
End Sub
Reply With Quote
  #6  
Old 23-01-2010
Member
 
Join Date: May 2008
Posts: 2,383
Re: Verify the content of the textbox with multiple buttons on Form

I do not see what prevents you from doing this:
Code:
Private Sub ManagementOfButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click, button2.Click
        If TextBox1.Text.Length < 5 Then
            MessageBox.Show("Thank you to comment")
        Else
            webrowser.navigate(TextBox1.Text)
        End If
End Sub
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Verify the content of the textbox with multiple buttons on Form"
Thread Thread Starter Forum Replies Last Post
Mass Effect 3 Promo Content form 7 Barnes and Noble Elwoody Video Games 7 19-03-2012 11:18 PM
Excel/VBA: Copying text from UserForm Textbox to a Worksheet Textbox Neil Ives Software Development 2 20-08-2010 01:23 AM
RegEx - verify content and size New ID Software Development 5 04-02-2010 01:27 AM
Problem of html form with multiple submit buttons ASHER Software Development 4 20-10-2009 05:31 PM
Several submit buttons in the same form ? Wiro Software Development 5 14-02-2009 10:29 PM


All times are GMT +5.5. The time now is 12:52 AM.