?
Solved

avoid exporting duplicate strings

Posted on 2014-11-27
7
Medium Priority
?
82 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 49

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 49

Accepted Solution

by:
Martin Liss earned 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 49

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 49

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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