|
Converting your Decimal value to Double may result in loss of precision. Instead, keep it Deciamal and use ToString() to display it in a certain format.
|
|
|
|
|
I am not sure which version of .Net you are using but in VS 2010(.Net 4.0) in a winforms app, this seems to be the default behaviour. I know if I want to always show the decimal part (500.00), that is when I need to go the ToString route. I just tested with a listbox and with textboxes, and I get no decimal points if the decimal is a whole number.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
From a general programming point of view you should never change your data type to satisfy display requirements, if by changing that datatype you remove precision.
Converting to a double will lose some precision.
Although very little precision is generally lost - if you are performing financial calculations this can cause a problem further on down the line when figures do not match.
So it really is better to stick with decimal and then to format it for display - otherwise you may be asking for trouble later when the FD asks "Why don't the totals match?"...
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
Hear, Hear.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
I agree with you.
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
I`m not too concerned with precision. At the moment it works perfectly - If I do have decimals it keeps the decimals and if I don't then it shows the whole number. I just tested this by creating a random decimal of 4.4567, converted it to a double and the value stayed the same
|
|
|
|
|
Etienne_123 wrote: ONLY show decimals
Show it where?
|
|
|
|
|
Etienne_123 wrote: I do not want to use string formattin
What is displayed on screen is a string that is currently using the default formatting, so doing a custom string format is the correct way. The sort should be done on the real values regardless of how it's displayed IMO, this way therer is no issue.
|
|
|
|
|
i'm developing a chemistry program i find this code in the program chemsketch
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ACD CHEMBASIC DEMO PROGRAM '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' '
' Molecular 3D Editor//MIRROR.BAS '
' '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' '
' The utility flips the molecule at a plane '
' '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
CONST TITLE="ChemBasic Molecular Editor // Mirror"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function Main As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' MIRROR.BAS '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim page,diag,asm,struc As Object, s As String, OK As Boolean
MAIN="Failed or nothing to do!"
' Get 1st structure from the curent page
page=ActiveDocument.ActivePage
If page.Diagrams.Count<1 Then Exit Function
diag=page.Diagrams.Item(1)
asm=Assemblies.AddFromCS(diag)
If asm=NULL Then Exit Function
struc=Asm.Structures.Item(1)
If struc=NULL Then Exit Function
' Do the job
s=UserIOBox("Flip X, Y, or Z coordinate ?" ,TITLE , "Y")
s=UCase(Left(s,1))
If s="X" OR s="Y" OR s="Z" Then
' Flip !
Call Flip(struc,s)
' Show the results
RefreshDiagram(diag,struc)
Main="Completed."
End If
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Flip(struc As Object,s As String)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim x,y,z As Double, asm,at As Object
With struc
asm=.Assembly
For Each at In asm
.GetAtomXYZ(at,x,y,z)
Select Case s
Case "X"
x=-x
Case "Y"
y=-y
Case "Z"
z=-z
End Select
.SetAtomXYZ(at,x,y,z)
Next at
End With
End Sub
'***LIBRARY PROCEDURES BEGIN
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub RefreshDiagram(diag As Object,strmol As Object)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' LIB0.BAS PROCEDURE '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Redraws the diagram with a molecule or structure object '
' '
' ENTER '
' diag object of type CS_DIAGRAM '
' strmol object of type CB_MOLECULE or CB_STRUCTURE '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim l,t,w,h,w1,h1 As Integer
diag.GetBound(l,t,w,h)
diag.Depict(strmol)
diag.GetBound(w,h,w1,h1)
diag.SetBound(l,t,w1,h1)
End Sub
'***LIBRARY PROCEDURES END
'@@@@@@
|
|
|
|
|
1. This is the C# forum, not VB.NET.
2. What is your question.
3. Please put your code between <pre> tags.
The best things in life are not things.
|
|
|
|
|
|
|
I guess you meant nearly a year, someone is in deep doo-doo.
The best things in life are not things.
|
|
|
|
|
In a year he could actually learn how to code properly
|
|
|
|
|
Are you sure?
The best things in life are not things.
|
|
|
|
|
In a year, one should be able to. This guy? Well, come to your own conclusion
|
|
|
|
|
Hi,
I would like to get "Token" value based on the description from the below xml file.
For example, if my input is 'Company'(Description), it should return 'COS'(Token).
I tried with XPath. But not working due to multi level of nodes in xml. Could you pls guide me to achieve this. Thanks in advance.
<CodeList>
<Entity>
<Token>PROD</Token>
<Description>prod</Description>
<Entity>
<Token>BUSINESS</Token>
<Description>Business News</Description>
<Entity>
<Token>COS</Token>
<Description>Company News</Description>
<Entity>
<Token>ANA</Token>
<Description>Analyst Ratings</Description>
<Entity>
<Token>ANAMOVES</Token>
<Description>Analyst Ratings, Estimates and Target Price Changes</Description>
<Entity>
<Token>ANACHANGE</Token>
<Description>Analyst Rating Changes</Description>
<Entity>
<Token>ANACUT</Token>
<Description>Analyst Downgrades</Description>
<Entity>
<Token>ANACUTEVT</Token>
<Description>Analyst Ratings Cut Events, Announcements</Description>
</Entity>
</Entity>
</Entity>
</Entity>
<Entity>
<Token>IP</Token>
<Description>Intellectual Property</Description>
<Entity>
<Token>COPYRIGHT</Token>
<Description>Copyrights</Description>
</Entity>
</Entity>
</Entity>
</Entity>
<Entity>
<Token>DRGPATENT</Token>
<Description>Drug Patents</Description>
</Entity>
</Entity>
</Entity>
</CodeList>
|
|
|
|
|
Use // to search in any level into your XML.
The following XPath will give you what you want:
//Entity[contains(./Description, 'Company')]/Token
|
|
|
|
|
Thank you Mirko1980, its working
|
|
|
|
|
You could use Linq to XML[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Good afternoon.
We created a control (somecontrol.cs) which displays a dynamic bullet list. In some scenerios, one of the bullets will have a hyperlink.
The problem is, the a href code renders as text. We are adding to a string List and using it as the DataSource for the bulleted list:
private BulletedList _blConfirmText = new BulletedList();
List<string> displayText = new List<string>();
_confirmText.Text = CONFIRMTEXTLB;
displayText.Add(BULLETONELB);
displayText.Add(BULLETTWOLB);
if (hasUpdateAccess)
displayText.Add(BULLETTHREELBHL);
else
displayText.Add(BULLETTHREELB);
_blConfirmText.CssClass = "bulletItems";
_blConfirmText.DataSource = displayText;
_blConfirmText.DataBind();
Any idea how to get this to render correctly? Any suggestions? Thank you, WHEELS
|
|
|
|
|
What type of control is it? Is it a WinForm User control?
There's no magic wand that will parse your href string and display it as a link automatically, you'll have to write your own logic to achieve this behavior.
EDIT: I see that you're trying to create some sort of a Web User Control. Can you show some code where the actual rendering happens?
|
|
|
|
|
private const string BULLETTHREELBHL = "This is an example of the hyperlink <a href=\"/../Test/FW_DEFAULT.ASPX?Serviceid=Test&title=Test+Page>Test Page\"</a> where people click to navigate to another page.";
|
|
|
|
|
Your HTML is invalid (the quotes around the attribute value aren't done right).
|
|
|
|
|
Hi Bob. What should they be? WHEELS
|
|
|
|
|