-
Aug 4th, 2020, 05:01 PM
#1
Thread Starter
Fanatic Member
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.
-
Aug 4th, 2020, 05:17 PM
#2
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.
-
Aug 4th, 2020, 06:58 PM
#3
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)
“They did not know it was impossible so they did it” (Mark Twain)
-
Aug 4th, 2020, 07:45 PM
#4
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.
-
Aug 5th, 2020, 10:37 AM
#5
Thread Starter
Fanatic Member
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.
-
Aug 5th, 2020, 07:23 PM
#6
Re: Cannot overwrite Combobox Value with new text
Originally Posted by ssabc
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|