hey all!
please help me to check for validaiton such that... i hv few textboxes and combo boxes and if data is not entered in them then the submit button should be locked... and also tell me where should i write the code as in .... in form_load or submit_click... im confused... the code i wrote was...
There are many ways to validate whether it is a text box or a button or submit button, the way you write the code and the place you put your code can be vary, depending upon your decision, one simple way is to write the validation code and make that code as public so that you can call it from any where and any time you need. Let me give you one example:
Public Sub ControlMyButton()
if MyText1.Text="" OR MyCombo.Text="" then
Submitbutton.enable=False
else
Submitbutton.enable=True
end if
End Sub
The above code can be easily called (Instead of writing in event of the form) like this:
Say in the KeyUp Event of the text Box:
Call ControlMyButton
Even, In the MyText1_Change, and in the form Load event you can called 'Call ControlMyButton'
So, Only when the textbox is filled, the button will be enabled.
I think this will give you an Idea. Try in different way. Its not difficult.
thanks a lot for the responses... but its not working... i tried each of them invidually... but it is not working...
sorry... pls do keep helping!
thnx!
No. None of them is a complete solution and nobody can give one without seeing the whole code.
There may be a just a little spot everyone's missed. Can you give more details?
But few things to try out:
Text may contain spaces, so trim them off like Trim(cname.Text) = ""
Then split your validation code to validate every control separately:
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline:Portability