Solved

Arrays to check duplicates in vb.net

Posted on 2016-07-25
8
38 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 9

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 9

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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Closing Comment

by:RIAS
ID: 41727537
Thanks!
0
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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