Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i have the following code which i need compact down so i don't have that many 'or's. can anyone help me as i am a novice and do not know any other way of doing this.

VB
If SourceC.Text.Contains("<script>") Or SourceC.Text.Contains("<object>") Or SourceC.Text.Contains("<embed>") Or SourceC.Text.Contains("<applet>") Or SourceC.Text.Contains(".lpk") Or SourceC.Text.Contains("<java>") Or SourceC.Text.Contains("<meta>") Or SourceC.Text.Contains("<iframe>") Or SourceC.Text.Contains("<link") Or SourceC.Text.Contains("vbscript") Or SourceC.Text.Contains("<blink>") Or SourceC.Text.Contains("<marquee>") Then
            MessageBox.Show("Yes, that string is in here!")
        Else
            MessageBox.Show("No, the string is not in here!")
        End If


can you please give an answer using code. any help much appreciated and thank you very much to any helpers.
Posted

1 solution

You could use the Select Case statement. The Select Case statement works like an If statement but makes code much easier to read :)

SQL
Select Case Console.ReadLine
    Case "hello"
        MsgBox("You typed hello")
    Case "world"
        MsgBox("You typed world")
    Case "test"
        MsgBox("You typed test")
    Case Else
        MsgBox("You typed something else!")
End Select



Obviously this code will need changing for your needs, but I hope this will help you. :) See here for more information: http://msdn.microsoft.com/en-us/library/cy37t14y(VS.80).aspx[^]
 
Share this answer
 
v2
Comments
piemangood 5-Sep-10 10:58am    
Reason for my vote of 2
jklk

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900