Friday 13 August 2010

Being my first entry for over a week and also my first since returning from holiday, I'd though I would do a nice and easy one on this Friday afternoon and demonstrate the switch and case statement in VB.Net and C#....

Firstly, it is important to remember that the case identities correspond to the value's given from the drop down menu or listbox etc....

Ok the code for use in VB.Net is....

Select Case ListBox1.SelectedValue

Case 1
MsgBox("hello")
Case 2
MsgBox("thanks")
Case 3
MsgBox("bye")
End Select


and for C# it's...

switch (DropDownList1.SelectedValue)

{ case "1":
MessageBox.Show("hello");
break;
case "2":

MessageBox.Show("thanks");
break;
case "3":

MessageBox.Show("bye");
break;}

No comments:

Post a Comment