LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default VB.Net ToString Number Format

Hi all, The below code displays result in 1,234.00 number format. So
if I have amount 2,000.49 in cell one and 2,000.01 in cell two of
datagridview the result should be 4,000.50 but below code displays it
4,001.00. How can I get the the decimals? Also if I want result to
be 4,001 instead of 4,001.00 in other words amount without decimals
then how can I achive it in below code. Please can any friend tell me
that what amendment in below code can give me the result i am looking
for.


Private Sub DataGridViewX2_SelectionChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DataGridViewX2.SelectionChanged
Dim OBC As Integer = 0
Dim currentRow As DataGridViewCell
For Each currentRow In DataGridViewX2.SelectedCells
If currentRow.ColumnIndex = 6 And
DataGridViewX2.SelectedCells.Count 1 Then
OBC += CInt(currentRow.Value)
ElseIf currentRow.ColumnIndex = 9 And
DataGridViewX2.SelectedCells.Count 1 Then
OBC += CInt(currentRow.Value)
Else
OBC += 0
End If
Next
LabelItem2.Visible = True
LabelItem3.Visible = True
If Microsoft.VisualBasic.Left(OBC.ToString, 1) = "-" Then
LabelItem3.Text = OBC.ToString("N")
LabelItem3.ForeColor = Color.Red
Else
LabelItem3.Text = OBC.ToString("N")
LabelItem3.ForeColor = Color.Black
End If
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace million-billion number format to lakhs-crores format Sumit Excel Discussion (Misc queries) 1 December 9th 05 04:58 PM
Change number (in text format) to numeric format Pam Excel Discussion (Misc queries) 5 October 24th 05 07:45 PM
convert text-format number to number in excel 2000%3f Larry Excel Discussion (Misc queries) 1 July 29th 05 08:18 PM
Number format based on number format of another cell in another workbook Rob Excel Programming 9 January 9th 05 04:30 PM
excel format cells/Number/Category: Number problem Matts Excel Discussion (Misc queries) 5 December 9th 04 09:47 PM


All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"