?
Solved

comparing values

Posted on 2014-01-17
2
Medium Priority
?
282 Views
Last Modified: 2014-01-17
hello I am having trouble figuring out a method to compare two values that seem to be the same, but the number of decimal places is affecting the logic and I am not sure how to format the values correctly.

One of the values is an entity record field = 100.00000000000000000000
The other value is from a detailsview cell = 100.00

When I run this code:

                    If String.Equals(myHistoryRecipeRecord.MeltPointHigh, DirectCast(dvRecipeItem.Rows(6).Cells(1).Controls(0), TextBox).Text) Then
                        strRefineRecipeRecord.Append("MeltPointHigh: " & myHistoryRecipeRecord.MeltPointHigh & ", ")
                    Else
                        strRefineRecipeRecord.Append("MeltPointHigh: Old= " & myHistoryRecipeRecord.MeltPointHigh &
                                                     ", New= " & DirectCast(dvRecipeItem.Rows(6).Cells(1).Controls(0), TextBox).Text & ", ")
                    End If

It always fall to the else because the number of decimal places.

I have search for examples on how to format decimals coming from an entity record field, but I have not found anything that I can understand.

If any one could please explain to me how this can be done, that would be great.

Thank you so much.
0
Comment
Question by:metropia
[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
2 Comments
 
LVL 13

Accepted Solution

by:
akb earned 2000 total points
ID: 39789623
The problem is that you are comparing strings, not numbers.

I don't program in Visual Basic.net but I think you need to use Convert.toDecimal().

i.e.
If  Convert.toDecimal(myHistoryRecipeRecord.MeltPointHigh =  Convert.toDecimal(DirectCast(dvRecipeItem.Rows(6).Cells(1).Controls(0), TextBox).Text) Then
                        strRefineRecipeRecord.Append("MeltPointHigh: " & myHistoryRecipeRecord.MeltPointHigh & ", ")
                    Else
                        strRefineRecipeRecord.Append("MeltPointHigh: Old= " & myHistoryRecipeRecord.MeltPointHigh &
                                                     ", New= " & DirectCast(dvRecipeItem.Rows(6).Cells(1).Controls(0), TextBox).Text & ", ")
                    End If
0
 

Author Comment

by:metropia
ID: 39789684
You got it!
0

Featured Post

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.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

762 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