Re: Raise Event and OnClick
If you do that you'll end up with a non-standard UI which will confuse your users.
However, if you just really want to do that a simple way would be to use a static boolean variable in the click event that is already provided.
Each time the event is raised you can respond as per the value of the boolean.
Simply continually change the boolean from true to false to true...each time the button is clicked and then do as you please with the code.
Re: Raise Event and OnClick
try this:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static clicks As Integer = 1
If clicks = 1 Then
'check your textbox
clicks += 1
Else
Label1.Visible = True 'or however you're revealing your hidden label
End If
End Sub
edit: or use a boolean as fourblades suggested
Re: Raise Event and OnClick
Ok how would I go about doing this
Re: Raise Event and OnClick
It is a program I am trying to write I have two button a submit button and a reset button. I enter a string into a textbox and press the submit button and if the string isn't the right lenght I get an error an a message box. After I press ok in the message box to get it off the screen I should press the reset button to clear the textbox. But if i don't press the reset button and press the submit button instead thats when the label is suppose to popup saying "please press the reset button".
Re: Raise Event and OnClick
Well then ignore my previous post.
What you want is different than what I thought.
Re: Raise Event and OnClick
Ok thanks I have figures out the rest of the program this is the only part that is giving me trouble I guess I will have to try to keep searching
Re: Raise Event and OnClick
Code:
Public Class frm_project
Dim WarningLabel As Boolean = False
then inside your private sub button, check for the boolean value before any other part of your statement. Then check the uservalue
Code:
If WarningLabel = True Then
lbl_ClearWarn.Visible = True
ElseIf uservalue.Length <> 12 Then
WarningLabel = True
MessageBox.Show("bla bla bla")
then set your Reset button to put the Boolean back to False, as well as your Label.Visible to False
Code:
WarningLabel = False
txt_UserWords.Text = "Reset Button"
'Clear the Red/Blue Warning Box
If lbl_ClearWarn.Visible = True Then
lbl_ClearWarn.Visible = False
End If
Re: Raise Event and OnClick
I think this will work:
Code:
Public Class Form1
Private MessageboxAlreadyShown As Boolean
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Me.Label1.Visible = False
End Sub
Private Sub ButtonSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSubmit.Click
If Not Me.TextBox1.Text.Length = 20 Then
Select Case True
Case MessageboxAlreadyShown = True
Me.Label1.Visible = True
Case MessageboxAlreadyShown = False
MessageBox.Show("Error Message")
MessageboxAlreadyShown = True
End Select
Else
'continue processing
MessageboxAlreadyShown = False
End If
End Sub
Private Sub ButtonReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonReset.Click
Me.TextBox1.Text = String.Empty
Me.Label1.Visible = False
MessageboxAlreadyShown = False
End Sub
End Class
Re: Raise Event and OnClick
Ooops minor problem. This will work as a user would expect:
Code:
Public Class Form1
Private MessageboxAlreadyShown As Boolean
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Me.Label1.Visible = False
End Sub
Private Sub ButtonSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSubmit.Click
If Not Me.TextBox1.Text.Length = 20 Then
Select Case True
Case MessageboxAlreadyShown = True
Me.Label1.Visible = True
Case MessageboxAlreadyShown = False
MessageBox.Show("Error Message")
MessageboxAlreadyShown = True
End Select
Else
Me.Label1.Visible = False
'continue processing
End If
End Sub
Private Sub ButtonReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonReset.Click
Me.TextBox1.Text = String.Empty
Me.Label1.Visible = False
MessageboxAlreadyShown = False
End Sub
End Class