Solved

avoid exporting duplicate strings

Posted on 2014-11-27
7
78 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
  • 4
  • 3
7 Comments
 
LVL 46

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 46

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 46

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 46

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

776 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