Well I have a combobox with 3 items namely: Product Size and Cost.

I have also a maskedtextbox.

If I select "Product" and "Size" on the combobox, I want to disable the maskedtextbox from filling, how must I do it?

Recommended Answers

All 10 Replies

Try the following -

If Combo1.Text = "Product" Or Combo1.Text = "Size" Then
MaskedEit1.Enabled = False
End If

Do this under your combo_click event.

Yes, it works but it makes all items disable like the Cost as well. Here my codes:

If cboType.Text = "Product" Or cboType.Text = "Size" Then
mtxtCategory.Enabled = False
End If

Try the following -

If Combo1.Text = "Product" Or Combo1.Text = "Size" Then
MaskedEit1.Enabled = False
End If

Do this under your combo_click event.

Yes, it works but it makes all items disable like the Cost as well. Here my codes:

If cboType.Text = "Product" Or cboType.Text = "Size" Then
mtxtCategory.Enabled = False
End If

Then try and change the If to a select statement -

Private Sub cboType_Click()
Select Case cboType.Text

Case Is = "Cost"
mtxtCategory.Enabled = True

Case Is = "Product"
mtxtCategory.Enabled = False

End Select
End Sub

Yes now its good, it works LOL, THANK YOU THANK YOU VERY MUCH YOU ARE GREAT...THANK YOU!

It's a pleasure, please mark this as solved, found at the bottom of this page, thanks.:)

Happy coding;)

By the way, do you know how to create a search box in Visual Basic? I want the search box based on streamreader. In proper terms, when I will input a text, it has to read on a text file in drice C. I know the streamreader code but don't know the code to do a search.

Yes you can, but it is off topic in this thread.:)

Please open a new thread, I'll answer from there, thanks.

I saw it, having a look right now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.