Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
2/22/2007 5:09:33 PM EDT
So my friend is trying to write a program for school and since I'm learning C++, I can't really help him.  

Basically, I need the basic code to make a messagebox appear when the value displayed in a label falls to 2.  Does the activation code go in the label definition or in the messagebox definition?  

Apparently his prof doesn't explain things well and the book sucks ass.  I looked and can't make heads or tails of it.
2/22/2007 5:18:51 PM EDT
[#1]
Assuming you are using VB.Net it will be something like this.  I used a TextBox in this sample but the label has the text changed event as well.  The activation is in the text changed event that is raised.  I put a sloppy exception handler around it to eat the exception rather than validation code.  You get bonus points if you validate the text before trying to convert it to an int.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

       Try
           If CInt(TextBox1.Text) < 2 Then
               MessageBox.Show("Hey dope - it's less than 2")
           End If
       Catch
       End Try

   End Sub
2/22/2007 5:31:39 PM EDT
[#2]
Thanks, I'll try that.

ETA:  It works!  Thanks much.