Solved

VBA double quote escaping question

Posted on 2016-10-06
8
36 Views
Last Modified: 2016-10-06
How do you compare two strings when one is
3"
and the other is "3"""
which is the same 3 inches but with the double quote within the string escaped.
I want to do a straight "is string equal"
0
Comment
Question by:Silas2
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 41832354
You could do

 If Val(first string) = Val(second string) Then
0
 
LVL 45

Assisted Solution

by:Martin Liss
Martin Liss earned 125 total points
ID: 41832364
Or in a formula, something like

=IF(SUBSTITUTE(A1,CHAR(34),"")=SUBSTITUTE(B1,CHAR(34),""),"Equal","Not equal")
0
 

Author Comment

by:Silas2
ID: 41832366
I was thinking along those lines, and stripping all the quotes out, but that's a bit crude and wouldn't catch quite a few possibilities, (although I have to think quite hard to come up with any but in large(ish) volumes there might be some)
0
 
LVL 75
ID: 41832382
If Replace(<SomeVar1>,Chr(34),"") = Replace (<SomeVar2>, Chr(34),"") then
 'whatever
Else
'whateverelse
Endif
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 45

Expert Comment

by:Martin Liss
ID: 41832406
I was thinking along those lines, and stripping all the quotes out, but that's a bit crude and wouldn't catch quite a few possibilities, (although I have to think quite hard to come up with any but in large(ish) volumes there might be some)
If you think of a possibility, let me know.
0
 
LVL 34

Assisted Solution

by:PatHartman
PatHartman earned 125 total points
ID: 41832434
That's just one of the many problems that mushing multiple attributes into a single field causes.  Use one field for just the number and the second for the unit of measure.  EVERY field should be atomic.  That's what first normal form specifies.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 250 total points
ID: 41832448
If only it were a perfect world :-)
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 41832516
I can't tell you how many of these situations I have fixed over the years.  It's almost always better to simply resolve the data problem by splitting the mushed field once.  Then everything else just works better.  Of course if you have no control over the table schema you're SOL.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

757 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now