TextBox Validation

George

Member
Joined
Jun 2, 2005
Messages
11
Programming Experience
Beginner
Hi there,

Could anybody help me with this code please ?

I have 8 text boxes inside a group box. I need to write the validation so that when the corresponding radio button is checked that the textbox firstly is not empty otherwise error message must appear and secondly that only a numerical value is allowed to be entered otherwise error message must appear.

Any help would be greatly appreciated.

Thanks
George
 
Catch the onChange event of Radio buttons but be sure that only single method is doing the trick

like you can have method like this
Private Sub MyChangeHandler(......) Handles RadioButton1.OnChange, RadioButton2.Onchange .....
End Sub


now inside the method you can write a general code
if (Sender == RadioButton1) then
validate textbox 1
elseif .......

so you can easily go to each one.
more solutions are possible but u know time is ...
 
hahahaha ... Sorry, I couldn't resist!! That's the biggest defect C# programmer has. Habit! If you trust me i stoped work with C# since i started to learn vb.NET syntax.

two equations == in vb.NET will throw an warning: Expression Expected

if (Sender = RadioButton1) then 'would be correct way ;)

Sorry ... but i couldn't stop laughing hysterically in my seat just because of how funny it is and mostly because i was also doing sucha obvious mistake/s at the beggining.

Cheers ;)


btw, take a look at this link http://www.codeproject.com/dotnet/vbnet_c__difference.asp
maybe you will find it useful
 
Oh its not a matter of bigining , actually i m currenlty working over more then five languages ranging (Java, Delphi, VB.NET , C#, VB) so getting confuse into syntax is not much issue :)
 
One tiny detail

Hi, guys. I must say I find this thread particularly hilarious. I mean the whole C# vs. VB syntax discussion is so funny. Although kulrom has a point, the (If Sender = RadioButton1 Then) sentence will throw a syntax error if you have the “Option Strict” set to “On” in your project properties. But even if you don’t, the most politically correct approach when comparing object variables is to use the “Is” instead of the “=” operator, it would something like this (If Sender Is RadioButton1 Then). I just thought I should add to the light-hearted discussion. Thanks for the good humor.
 
Back
Top