Results 1 to 6 of 6

Thread: Cannot overwrite Combobox Value with new text

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    Minneapolis, MN
    Posts
    399

    Cannot overwrite Combobox Value with new text

    Hello:

    Is this not allowed?

    Code:
        Private Sub cboJobNo_TextChanged(sender As Object, e As EventArgs) Handles cboJobNo.TextChanged
            Dim txt As String = cboJobNo.Text
            Dim txt2 As String = Microsoft.VisualBasic.Left(txt, 9)
            cboJobNo.Text = txt2
    
        End Sub

    Thanks.

  2. #2
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,695

    Re: Cannot overwrite Combobox Value with new text

    Did you get any errors? If not, then it is probably allowed. If it did not do what you were expecting, that is a different question.

    Did you put a break point on each statement and then check to see what the various values were? That might give you an idea about what is or is not happening.

  3. #3
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    346

    Re: Cannot overwrite Combobox Value with new text

    Hello,

    I tested your code and it is working exactly as expected, it cut after 9 character,s put the cursor at the beginning and then cut the 10th character as you enter more character at the beginning.
    What did you expect ?

    regards
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,478

    Re: Cannot overwrite Combobox Value with new text

    Try providing a FULL and CLEAR explanation of the problem. What happened that you didn't expect? What didn't happen that you did expect? If there was an error message generated, provide it, as well as where it occurred and when, i.e. at compile time or run time.

    Apart from that, why would you think that changing the Text of a control when the Text of that control changes would be a good idea? Part of a good question is explaining what you're actually trying to achieve. In this case, there's little chance that that code would or could achieve anything desirable. You are likely handling the wrong event and/or working with the wrong property but we shouldn't really have to guess what you're trying to do from code that doesn't do it.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    Minneapolis, MN
    Posts
    399

    Re: Cannot overwrite Combobox Value with new text

    Thank you! I was not sure if it was disallowed of if I have something else going on.

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,478

    Re: Cannot overwrite Combobox Value with new text

    Quote Originally Posted by ssabc View Post
    I was not sure if it was disallowed
    Why would you be unsure? Anything that compiles is allowed and anything that doesn't compile is not allowed. You don't need us to tell you whether something compiles or not. Whether or not code that compiles does anything useful or sensible is a completely different matter, but context is required to determine that.

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