Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.Net: test multiple values for equality?

How do you test multiple values for equality in one line? Basically I want to do

if (val1 == val2 == val3 == ... valN)

but in VB.Net.

like image 975
mcjabberz Avatar asked Dec 30 '22 03:12

mcjabberz


2 Answers

If val1 = valN AndAlso val2 = valN AndAlso ... Then
End If

This can get cumbersome when testing more than a few values.

like image 76
Jim H. Avatar answered Jan 05 '23 18:01

Jim H.


There is no way to chain them together like that. You need to break it up into pair'd comparisions linked by AndAlso

if val1 = val2 AndAlso val2 = val3 AndAlso val1 = val3 Then
like image 36
JaredPar Avatar answered Jan 05 '23 19:01

JaredPar