Results 1 to 6 of 6

Thread: [2008] perform action if value = 15 and descending

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    99

    [2008] perform action if value = 15 and descending

    Hello folks,

    can i detect if a text box is showing 15 and descending and then perform an action?

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] perform action if value = 15 and descending

    Hey,

    How are you wanting to go about doing this detection?

    Is it based on the user clicking a button? Or is it when the user enters something into the textbox and then leaves the textbox?

    Can you provide some more information?

    If for instance you wanted to do it on the click event of a button, you could use:

    Code:
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            If TextBox1.Text <> String.Empty AndAlso CInt(TextBox1.Text) <= 15 Then
                MessageBox.Show("Entry is less than or equal to 15")
            End If
        End Sub
    If however, you wanted to do it when the user left the textbox, you could do the same as the above, but you might want to use the Leave Event, or the TextChanged Event.
    Gary

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2008] perform action if value = 15 and descending

    As gep said, depending on where you want to use the code will determine in which event handler you will place the code, but your code would look something like this:

    Code:
            Dim result As Integer
            If Integer.TryParse(TextBox1.Text, result) AndAlso result <= 15 Then
                ' Do Some action
            End If

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] perform action if value = 15 and descending

    Agreed, should use the Integer.TryParse rather then CInt.

    Gary

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    99

    Re: [2008] perform action if value = 15 and descending

    thanks guys for your suggestions.

    To add to my question

    The information is automatically populated from another application which is updated via a timer so every ten seconds it updates

    The number goes up and down I only want to do an action when its at 15 and descending

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] perform action if value = 15 and descending

    Sounds like the TextChanged Event is the one that you are after then.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width