Avatar of RIAS
RIAS
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Arrays to check duplicates in vb.net

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?
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
RIAS

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Paweł

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
RIAS

ASKER
Paweł,
Cheers! Any suggestion how can i use it my code...
Paweł

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.
RIAS

ASKER
Thanks!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
wsh2

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"
wsh2

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"
wsh2

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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
RIAS

ASKER
Cheers!