Solved

avoid exporting duplicate strings

Posted on 2014-11-27
7
81 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
Independent Software Vendors: 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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