RIAS
asked on
vb.net currency display has four zeros instead of two
Hello,
How to make it display two zeros:
Public Sub Populate(ByVal Command As SqlCommand)
'Accept command as string and fill the datatable with the result of sql query
' Test_Str = "Test"
Dim dt = New DataTable
Dim SQLdr As SqlDataReader
Try
SQLdr = Command.ExecuteReader()
dt.BeginLoadData()
dt.Load(SQLdr)
dt.EndLoadData()
Command.Connection.Close()
Command.Dispose()
Data_Table = dt
Catch ex As Exception
MessageBox.Show(ex.ToStrin g)
End Try
End Sub
How to make it display two zeros:
Public Sub Populate(ByVal Command As SqlCommand)
'Accept command as string and fill the datatable with the result of sql query
' Test_Str = "Test"
Dim dt = New DataTable
Dim SQLdr As SqlDataReader
Try
SQLdr = Command.ExecuteReader()
dt.BeginLoadData()
dt.Load(SQLdr)
dt.EndLoadData()
Command.Connection.Close()
Command.Dispose()
Data_Table = dt
Catch ex As Exception
MessageBox.Show(ex.ToStrin
End Try
End Sub
I don't see anything showing values. The 4 digits are surely coming from the database. The formatting has to be done on the client but it varies according to the control. So which control is showing your data?
ASKER
Datagridview and radtextbox
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks it worked like a charm!
ASKER
Any suggestion on
sender.Rows(intRowIndex).C ells("Tota lPaid").va lue to display only two zeroes.
Cheers
sender.Rows(intRowIndex).C
Cheers
what is the issue? can't you set the column format like you did previously?
ASKER
str_TotalPaid = sender.Rows(intRowIndex).C ells("Tota lPaid").va lue
Sender is datagridview .
it worked to display the value in gridview correctly but when I extract the row it still shows with four values after decimal?
Sender is datagridview .
it worked to display the value in gridview correctly but when I extract the row it still shows with four values after decimal?
how is str_TotalPaid declared? as a string?
str_TotalPaid = sender.Rows(intRowIndex).Cells("TotalPaid").value.ToString("N2")
ASKER
Cheers Sir!
ASKER
Hello Éric Moreau,
str_TotalPaid is a string
Got an error N2 to type integer is not valid.
str_TotalPaid is a string
Got an error N2 to type integer is not valid.
which error? try this:
The ToString is @ https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx
dim decTotal as decimal = convert.todecimal(sender.Rows(intRowIndex).Cells("TotalPaid").value)
str_TotalPaid = decTotal.ToString("N2")
The ToString is @ https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx
ASKER
Thanks !