Solved

Arrays to check duplicates in vb.net

Posted on 2016-07-25
8
31 Views
Last Modified: 2016-07-25
Hi,

How to check if array has a string.Three checks on Uppercase,mixed case and lowercase.

 If IsDBNull(SQLdr(StrCol1)) = False Then
                    StrColval1 = SQLdr(StrCol1).ToString
                    StrColval1 = StrColval1.Trim
                    If StrColval1 <> String.Empty Then
                        If Not (Arr1.Contains(StrColval1)) Then
                            If Not Arr1.Contains(StrColval1.ToLower) Then
                                Arr1.Add(StrColval1)
                            End If
                        End If
                        End If
                End If

Any better way of doing this?
0
Comment
Question by:RIAS
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Accepted Solution

by:
Paweł earned 500 total points
ID: 41727511
yes use the following
https://msdn.microsoft.com/en-us/library/zkcaxw5y(v=vs.110).aspx

loop through your array and just compare once

Dim myString =""
For Each lstString As String In lst
    if(String.Compare(myString, lstString, true))
    'found string

   end if
Next
0
 

Author Comment

by:RIAS
ID: 41727514
Paweł,
Cheers! Any suggestion how can i use it my code...
0
 
LVL 8

Expert Comment

by:Paweł
ID: 41727515
check the comment again, i added a snippet, be weary of the syntax, it's been a long time since i've used Visual Basic.
0
 

Author Closing Comment

by:RIAS
ID: 41727537
Thanks!
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 14

Expert Comment

by:wsh2
ID: 41727540
Air-coded:
 
Dim strFind as string = "abc"
Dim str1st As String = "ABCd, abcd, AbCd)
Dim str2nd As String
'
str2nd = str1st.Upper.Replace(strFind.Upper, "")
MsgBox _
   ((str1st.Length - str2nd.Length) / str1st.Length).ToString & " occurences found"
1
 
LVL 14

Expert Comment

by:wsh2
ID: 41727541
Air-coded:
 
Dim strFind as string = "abc"
Dim str1st As String = "ABCd, abcd, AbCd)
Dim str2nd As String
'
str2nd = str1st.Upper.Replace(strFind.Upper, "")
MsgBox _
   ((str1st.Length - str2nd.Length) / str1st.Length).ToString & " Occurences Found"
1
 
LVL 14

Expert Comment

by:wsh2
ID: 41727542
Correction:

Dim strFind as string = "abc"
Dim str1st As String = "ABCd, abcd, AbCd)
Dim str2nd As String
'
If strFind.Length > 0 Then
    str2nd = str1st.Upper.Replace(strFind.Upper, "")
    MsgBox _
       ((str1st.Length - str2nd.Length) / strFind.Length).ToString & " Occurences Found"
End If
1
 

Author Comment

by:RIAS
ID: 41727631
Cheers!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now