djshades2004

Happy New Year VB Programmers!!!!

Im having a few probs with this one:

Private Sub ItemsDataGridView_RowLeave(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ItemsDataGridView.RowLeave

Dim i As Integer

Dim total As Double = 0

Try

For i = 0 To ItemsDataGridView.RowCount - 1

ItemsDataGridView.Item(3, i).Value = ItemsDataGridView.Item(0, i).Value * ItemsDataGridView.Item(2, i).Value

total += ItemsDataGridView.Item(3, i).Value

Next

textbox1.text = "" + total.tostring

Catch ex As Exception

MessageBox.Show("Error With Calculation, Please Try Again")

End Try

End Sub

Ive put this code on my Row leave as you can see. The problems I got is with the total. It will Only display as:

42 Instead of 42.00

Same as when you got:

42.40 it displays 42.4

How can I display leading zeros after the dicimal place thanks stu



Re: Visual Basic Express Edition Total Troublesome

ReneeC

In hElp see the Format Function used with the Currency option.






Re: Visual Basic Express Edition Total Troublesome

djshades2004

Thanks ReneeC. Your be amazed what you find when you actually do a search oops. lol.

For anyone that would like to know this is e.g code to achieve what I wanted to do.

TextBox1.Text = CType(total, Decimal).ToString("c")