Results 1 to 10 of 10

Thread: Executing textbox TextChanged code without changing the text

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2011
    Location
    Melbourne
    Posts
    37

    Executing textbox TextChanged code without changing the text

    I want to execute my “textbox changed” code (1) when I change the code in my text box, and (2) in other places in my code.

    I would like to do this without creating a separate subroutine, as I have done in the following example:

    Code:
    Sub GetIterMax()
        ‘ My code for getting the maximum number of iterations
    End sub
    
    Private Sub TbxIterMax_TextChanged(sender As System.Object, e As EventArgs) Handles tbxIterMax.TextChanged
            GetIterMax()
    End Sub
    Chat AI suggested two things that generated error messages. They were:

    Code:
    tbxIterMax.OnTextChanged(New EventArgs())
    Error BC30390” TextBoxBase.Protected Overrides Sub OnTextChanged(e As EventArgs)' is not accessible in this context because it is 'Protected'.
    
    RaiseEvent tbxIterMax.TextChanged(tbxIterMax, New EventArgs())
    Error BC30676: tbxIterMax is not an event of form1
    Let’s see if humans can do better.

    I’m using Visual Basic in Visual Studio 2022.
    Windows 11
    Last edited by dday9; Mar 22nd, 2023 at 08:24 AM.

Tags for this Thread

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