Solved

avoid exporting duplicate strings

Posted on 2014-11-27
7
79 Views
Last Modified: 2014-11-27
In the following project, I am modifying websites from a text file in an MSFlexGrid.  What is needed is a way to check whether the newly added entries are already duplicated before exporting them to the text file again.  

How can I put a msgbox or test in place to avoid duplication?

Also, how can I sort the sites in alphabetical order?
CB.zip
0
Comment
Question by:al4629740
[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
  • 4
  • 3
7 Comments
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40469509
When you say alphabetical order are you talking just about what you see in the grid? If so that is probably not too hard, but if you are also talking about the output file that's not possible unless the output file consists of only the records that start with "^" and not records like "ALLOW_DROPBOX_r05-02-2013".
0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40469535
To avoid duplication, replace the current ValidWebsite  function with this one.
Private Function ValidWebsite() As Boolean
Dim intPos As Integer
Dim lngIndex As Long

If Not txtEdit.Visible Then
    ValidWebsite = True
    Exit Function
End If

intPos = InStrRev(txtEdit.Text, ".")
' The "Len" portion of the following makes sure that there's
' something following the dot
If intPos = 0 Or intPos = Len(txtEdit.Text) Then
    MsgBox "The website name must have a domain", vbExclamation + vbOKOnly, "Missing Domain Name"
    txtEdit.SetFocus
    Exit Function
End If

For lngIndex = 0 To MSFlexGrid1.Rows - 1
    If UCase(MSFlexGrid1.TextMatrix(lngIndex, 0)) = UCase(txtEdit.Text) Then
        MsgBox "The website name '" & txtEdit.Text & "' already exists", vbExclamation + vbOKOnly, "Missing Domain Name"
        txtEdit.SetFocus
        Exit Function
   End If
Next

ValidWebsite = True
End Function

Open in new window

0
 

Author Comment

by:al4629740
ID: 40469544
alphabetical in the grid only
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Expert Comment

by:Martin Liss
ID: 40469546
Phew! It's still going to be tricky but I'll give it a try.
0
 

Author Comment

by:al4629740
ID: 40469566
I'll open it in another question
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40469570
Thanks, I appreciate that.
0
 

Author Comment

by:al4629740
ID: 40469573
Nope, I appreciate your help
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 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