I have been primarily a C/C++ developer and then moved on to C#. I have done some VB and VB.Net development in the past but not very actively. For last few months I have been involved in lot of VB.Net projects. Every now and then I run into situations where I know how something will be done in C# but not sure how to do it in VB.Net. I mean what will be syntax or statements used in VB.Net that are equivalent to same actions in C#. Yesterday one of my co-workers asked me "What is equivalent of C# Switch statement in VB.Net?". Since I was doing VB.Net development for a prototype project, I quickly answered him "Select Case is equivalent to Switch statement". I thought I will quickly publish this small not showing how Select Case is used in VB.Net.
For example I want to take different action based on what item has been selected in a combo box in my winforms application.
C#
switch(myCombo.SelectedIndex) { case 0: do1(); break; case 1: do2(); break; case 2: do3(); break; default: doNothing(); break; } |
VB.Net
Select Case(myCombo.SelectedIndex) Case 0 do1() Case 1 do2() Case 2 do3() Case Else doNothing() End Select |
How to plan CCSP Exam preparation
Develop a MongoDB pipeline to transform data into time buckets
Alert and Confirm pop up using BootBox in AngularJS
AngularJS Grouped Bar Chart and Line Chart using D3
How to lock and unlock account in Asp.Net Identity provider
2025 © Byteblocks, ALL Rights Reserved. Privacy Policy | Terms of Use