Decimal Values Are Being Retained?
Sep 27, 2010
I have two functions that return a dollar amount but one of the amounts extends out to more than 2 decimal positions. So I'm trying to round it to two decimal positions and for some reason after the amounts are added together it goes back to extending out more than 2 decimals. I have tried several things. Currently I'm trying to even use a string variable in-between conversions to see if I can get rid of the decimal values but it's still not working.
Here is the first function.
Public Function dTotalDollars(Optional ByVal iClassAccountIndex As Short = -1, _
Optional ByVal iBreakdownCode As DOLLAR_AMOUNT = DOLLAR_AMOUNT.ALL_DOLLARS) As Double
Dim dAmount As Double
[Code].....
Then after the second call it's showing in debug mode that dTotalCalcDollars is going to return 2272.37, but once it adds it to dAmount the amount becomes 28094.739999999998 instead of 28094.74.
View 4 Replies
ADVERTISEMENT
Sep 14, 2010
I am passing the degree values in the form of "123:09:89".I want to convert this value into its exact decimal value.
View 6 Replies
Nov 9, 2010
A user logs in by inserting their user id and password.If they don't have an email address assigned to their login details they are asked to submit one before they can continue.They then continue to the home page in a logged in state.The trouble I'm having is that the user id and password are not retained when they submit their email address so the login fails.
Here's the code...
Dim userid as String
Dim password as String
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
[code]....
View 1 Replies
Jan 24, 2011
I can enter data into the grid and have an working update command when the row leave event occursProblem comes when I click into the other datagridview the previous cell in the previous datagridview highlights and the cell in the datagrid view I click on highlights I can edit data in the other datagrid view but as long as that highlight is on in theprevious datagridview I cannot shut down my program with the close button. I must first go back to that other datagrid view and click on it once to lose that highlighted cell and then close. I don't get any errors during this time just can't shut down program.
View 7 Replies
Jan 28, 2009
I have VB.Net Exp 2008 with SQL Exp 2008, on a windows form I have 6 databound textboxes and 6 unbound textboxes, in the bound textboxes the records show as the bound dataGridView rows are selected, in the unbound textboxes is where I will enter the new record to be sent to the database. Added an SQL database in the designer which gave me a dataset(MdDB1DataSet) and a tableAdapter(MdTBTableAdapter). My problem is with adding, updating and deleting records. The add records button addes it during debug to the dataGridView, but does not return when I debug again. So this means it is not added to the database. The update button updates the fields in the DGV, but no record was retained.
Add Record button:
Dim nr As DataRow = MdDB1DataSet.Tables(mdTb).NewRow
nr(0) = Trim(txtAdd1.Text)
nr(1) = Trim(txtAdd2.Text)
nr(2) = Trim(txtAdd3.Text)
nr(3) = Trim(txtAdd4.Text)
[Code] .....
View 12 Replies
Jun 27, 2012
What is the cleanest, most readable way to String.Format a decimal with the following criteria
start with a sign symbol (+ or -)
a fixed number of fraction digits
no decimal separator
right aligned
pre-padded with "0"'s
View 3 Replies
Sep 27, 2009
I am started learning .net. I want two decimal points value. I have used this codelblNo.Text = Math.Round(CDec(txtNo.Text + (txtNo.Text * 0.2)), 2).ToString(If i have value as 1.32 then its ok but if i have value like 2.3 it shows 2.3 but i want value as 2.30
View 4 Replies
Apr 13, 2012
I have a dataset that contains decimal values pulled from a database, when I try to assign the values in it to variables, the decimal values somehow got rounded to a whole number. I have manually ran the query which selects a column of decimal(18,4) datatype and verified that the output contains decimal places. During the breakpoint, I also found out that the (dtr(c.ColumnName)) actually becomes an integer.
Dim bannerValsAmt(1) As Decimal
Dim bannerVals(1) As String
Dim i As Integer
[Code].....
View 1 Replies
Jan 1, 2012
I wish to display values of 2 decimal places whenever this field (datatype = smallmoney) is being read & displayed via a SQL select statement. Is there a simpler way out besides the following example? Im using VS 2008,
CONVERT(varchar, CONVERT(smallmoney, ABS(reading_i - reading_f)), 2 )
View 1 Replies
Jul 18, 2010
I have my form set in french as well, and it automatically changes the text format to use ','. However When I try to insert my values into the database it says cannot convert nvarchar to decimal? Worst case, Is there a way I can disable the numbers from changing to use ',' and just use '.' always regardless what language it is? My working language is vb.net?
View 1 Replies
Apr 25, 2011
How would I convert the two individual byte values (in hex) to a decimal value representing the concatenated hex values? For example, if I have the
Dim byte1 As Byte = &H99
Dim byte2 As Byte = &H99
' I want the decimal representation of the hex value "9999" ' (byte1.ToString + byte2.ToString) which should be "39321" Currently I use the following code:
Dim decVal as integer
decVal = Val("&H" + Hex$(byte1).ToString + Hex$(byte2).ToString)
However, when I use this, the value (decVal) comes out to "-26215"
View 2 Replies
Jul 12, 2011
I'm drawing polygons,lines,etc. and I have to have the points of each precise - up to 12 decimals. Since a Point only takes integer values, I'm not sure how to handle scaling. I have a working user control, but rounding the decimals so I can put them into points is causing incorrect calculations (area, ect.).
View 4 Replies
May 3, 2010
I'm trying to limit the number of decimal values to 3 in numbers such as .3125 but I also have numbers such as .5 which I need to leave as is.
how can I determine if a number is 4 decimal places and cut off the last number.. I don't want to round up either.. .3125 should be .312 not .313 and .5 should stay at .5 and not .500.
View 19 Replies
May 3, 2012
I have my form set in french as well, and it automatically changes the text format to use ','. However When I try to insert my values to the database it says cannot convert nvarchar to decimal? Worst case, Is there a way I can disable the numbers from changing to use ',' and just use '.' always regardless what language it is?
View 1 Replies
May 17, 2012
Is it possible to create a plot from List(Of Decimal) values in Excel with VB? I would like to avoid dumping data directly into a table, then creating the chart from that. Here is what I have so far, but I am getting a data type mismatch when I try to assign .XValues and .Values to the list. Is there some sort of conversion that needs to happen to turn a list into a series?
Dim Series As Excel.Series
Dim xVals As New List(Of Decimal)(New Decimal() {1, 3, 4, 5})
Dim yVals As New List(Of Decimal)(New Decimal() {2, 2, 2, 2})
[code].....
View 2 Replies
Apr 24, 2010
Is there such a thing as a type similar to a point, but contains a pair of decimals, or a pair of doubles, rather than integers? I searched the forums and google with no luck. I can't believe this has never come up before, I must have been using the wrong search terms.
View 4 Replies
Jul 2, 2009
In the discussion in this thread: [URL] it was reveiled to me that vb.net, using double, could only calculate values up to 18 digits after decimal.... so I started thinking and came up with this class
Public Class LargeNumber
Private pNumber As String
Public Sub New()
[CODE].............
I want to split the string into a series of doubles.... and than combine them into a large number.... The size of each double component should be 18 digits on a 32 bit computer... so that I will have room to add the last carrier...
View 3 Replies
May 30, 2011
Create a function named DecimalDegrees to refactor the code that converts a latitude or longitude into a value in decimal degrees. (This function will be used inside the functions ValueOf and Distance.)
Task 2a: Write the code for the function DecimalDegrees with an input parameter for DegreeString as type string, and returns the value as type Double.
Here is my code for the function part
Private Function DecimalDegrees(ByVal DegreeString As String, ByVal degrees As Double, ByVal minutes As Double,
ByVal seconds As Double, ByVal ID As Integer) As Double
I am having difficulties with the 2nd part which is I believe to take the code for the calc1 and calc2 buttons and somehow get it to convert to decimal degrees by the function I have created. The buttons would then be removed as the code would automatically take the latitude and longitude and convert the degrees, minutes and seconds into a decimal.
Here is the code for the current buttons:
Dim StartPtr, StopPtr As Integer
'To Replace Calculator 1 Button
'Convert degrees before passing argument - Latitude
StartPtr = 0
[Code] .....
View 9 Replies
Jun 22, 2010
Does anyone have any vb.net or vba code that will format excel values or a range of cells to have comma for 100s, 1000s,10000s etc
View 1 Replies
Sep 2, 2011
To pass decimal values to radio buttons so I can calculate an output answer. it is a tip calculator. I am using radio buttons as options to choose what amount to tip, ie. 10, 15, and 20%. I need to figure out how to pass the value to the buttons in code so I can calculate the tip amount.
View 1 Replies
Dec 20, 2010
how do you convert a decimal ( decimal place holder = dot) to a decimal (decimal place holder =comma)?
View 6 Replies
Oct 19, 2010
OdbcDataReader in showing decimal fields Decimal separator disappear with DB2 dsn
View 3 Replies
Aug 27, 2009
After converting all degrees-->decimal, and decimal-->hours, how can i use Tan, Cos and Sin formula in vb.net? I want the user must enter an input (which it is a coordinat-->i already convert the degrees-->decimal value as suggested by stanav and paul.
The questions like this (i only calculate on paper but dont know how to implement in code):
Input user need to enter:
-latitude local (e.g. 1.4875)
-longitude local (e.g. 103.3883333)
[CODE]...
View 23 Replies
Jan 17, 2011
My user requests to change the . on the numpad to a when entering text in a multiline textbox.So I was thinking about the KeyDown event.To determine if the numpad . was pressed I can do something like this [code]But now how do I change the returned charachter as a , ? All e.Key... properties are ReadOnly. The KeyPress events let me change this by providing e.KeyChar, but in that event I can't check for the numpad .
View 2 Replies
Apr 17, 2010
How would I go about rounding up decimal numbers to the nearest 2 decimal places? For example $7.0000032 would be $7.01 In theory, VB would make it $7.00 but if it is > $7.00, I want it to reflect that to the nearest penny... so $3.0000001 would be $3.01
View 5 Replies
Mar 30, 2011
If I have the code:Dim x as Decimal = 100.0m
Is it casting from a double to a decimal implicitly. How would I do this explicitly in vb.net?
View 2 Replies
Dec 21, 2010
1) One Decimal Varibale stores a decimal value
2) The value must be converted in string ( some time the comma is used as decimalplaceholder some time the dot)
3) the user modifies the value
4) i need to riconvert the string back in decimal
how can i do this
so:
Variable 123.34D ----> textBox 123,34 or 123.34 -----> variable 123.34D
View 3 Replies
Apr 23, 2010
Is there a way in VB .NET to have a decimal variable with 40 decimal places?
View 3 Replies
Dec 2, 2010
Maybe this is just a really basic question that everyone knows the answer to, and is why I couldn't find the answer. What I want to do is pretty simple. I want to declare a custom type that's just like a Single, except when you access the value, you get the value rounded to the second or third decimal place. Something like this:
Dim MyNumer as TwoDecimalNumber
MyNumer = 1.124
Msgbox(MyNumber) 'This would pop up a box showing "1.12"
[Code]....
View 8 Replies
Mar 13, 2009
Problem: Using the sub routing below, when adding a value to another value the results eventually change from 2-decimal places to multiple decimal places.Basically, the amount stored should always only be 2 decimal places, because the values passed in are always 2 decimal places. Output from calling the sub routine multiple times.
Running total = 329430.75
New Withheld Amount = 710.79
Running total = 330141.54
[code]....
As a workaround, I have a new routine that uses a custom round function to properly store only 2 decimal places - as the VB round function does not perform the type of rounding desired.I understand that we are removing the value from the dictionary and adding it back..
View 2 Replies