Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Need help with Listview Comparer

Posted on 2014-04-28
Medium Priority
Last Modified: 2014-04-28
Experts, I received some help previously on this topic for another project at Listview Comparer Help.

This worked fine for that particular project, but in a new project that i am working on it does not sort currency properly when there is a wide range of values.

In the attached screen shot i have show what it does with the currencies.

Screen Shot
Question by:Basicfarmer
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
LVL 41

Expert Comment

by:Kyle Abrahams
ID: 40027720
It's comparing by a string rather than by decimal.  

Update your code to ignore the $.

string_x = item_x.SubItems(m_ColumnNumber).Text.Replace("$","")

string_y = item_y.SubItems(m_ColumnNumber).Text.Replace("$","")

Author Comment

ID: 40027764
I tried this and it does the same thing.
If Decimal.TryParse(Replace(string_x, "$", ""), flags, Nothing, dec_x) And Decimal.TryParse(Replace(string_y, "$", ""), flags, Nothing, dec_y) Then

Open in new window


Author Comment

ID: 40027805
With the code the way it was to start with, at the break point I can see that the value of dec_x and dec_y are in fact decimal values.
 Screen Shot
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

LVL 41

Expert Comment

by:Kyle Abrahams
ID: 40028058
Are you using a string format to set the currency?  What if you take that out?  Does it work?

Author Comment

ID: 40028090
I am using formatCurrency for the item in that column.
lstItem.SubItems.Add(FormatCurrency(reader.Item("IDTCost"), 2))

Open in new window

When i take it out it sorts properly.
I dont know why it is not working the way it is setup already. The TryParse is working using the flags and dec_x and dec_y are converted to decimal properly.
LVL 41

Accepted Solution

Kyle Abrahams earned 2000 total points
ID: 40028283
Add this to your flags:

'... = the other globalizations you already have.  Add AllowThousands at the end.

flags = ... OR ... OR System.Globalization.NumberStyles.AllowThousands

Author Closing Comment

ID: 40028365
Perfect!!! Thank you...

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

618 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