I had my DGV working exactly the way I wanted it to. Now it's broken and I can't figure out what's wrong.
My form load has this and it was working great....
First, I'm confused as with cdbl, val, substring as far as which to use, when. I read val will return a string as a double and cdbl will return an expression as a double. I've also seen substring x,x used to get decimal values..
I'll probably need to reveal more code before this is resolved but could someone please tell me if I have val an cdbl used correctly here>
My form load has this and it was working great....
VB.NET:
[COLOR=green]'format DGV1 formulated colums for proper number type[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.Columns.Item(4).DefaultCellStyle.Format = [COLOR=#a31515]"n1"[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.Columns.Item(5).DefaultCellStyle.Format = [COLOR=#a31515]"n3"[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.Columns.Item(6).DefaultCellStyle.Format = [COLOR=#a31515]"n3"[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.Columns.Item(7).DefaultCellStyle.Format = [COLOR=#a31515]"n3"[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.Columns.Item(8).DefaultCellStyle.Format = [COLOR=#a31515]"n1"[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.Columns.Item(9).DefaultCellStyle.Format = [COLOR=#a31515]"n1"[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.AllowUserToResizeColumns = [COLOR=blue]True[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.AllowUserToOrderColumns = [COLOR=blue]False[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.MultiSelect = [COLOR=blue]True[/COLOR]
[COLOR=green]'decimal formatting because the dgv source is a datatable generated by Sub "DataGridViewToDataTable"[/COLOR]
[COLOR=blue]Me[/COLOR].DGV1.Columns(0).ValueType = [COLOR=blue]GetType[/COLOR]([COLOR=blue]Double[/COLOR])
[COLOR=blue]Me[/COLOR].DGV1.Columns(4).ValueType = [COLOR=blue]GetType[/COLOR]([COLOR=blue]Double[/COLOR])
[COLOR=blue]Me[/COLOR].DGV1.Columns(5).ValueType = [COLOR=blue]GetType[/COLOR]([COLOR=blue]Double[/COLOR])
[COLOR=blue]Me[/COLOR].DGV1.Columns(6).ValueType = [COLOR=blue]GetType[/COLOR]([COLOR=blue]Double[/COLOR])
[COLOR=blue]Me[/COLOR].DGV1.Columns(7).ValueType = [COLOR=blue]GetType[/COLOR]([COLOR=blue]Double[/COLOR])
[COLOR=blue]Me[/COLOR].DGV1.Columns(8).ValueType = [COLOR=blue]GetType[/COLOR]([COLOR=blue]Double[/COLOR])
[COLOR=blue]Me[/COLOR].DGV1.Columns(9).ValueType = [COLOR=blue]GetType[/COLOR]([COLOR=blue]Double[/COLOR])
First, I'm confused as with cdbl, val, substring as far as which to use, when. I read val will return a string as a double and cdbl will return an expression as a double. I've also seen substring x,x used to get decimal values..
I'll probably need to reveal more code before this is resolved but could someone please tell me if I have val an cdbl used correctly here>
VB.NET:
[COLOR=blue]Private[/COLOR] [COLOR=blue]Sub[/COLOR] TBoxInThroatDiam_TextChanged([COLOR=blue]ByVal[/COLOR] sender [COLOR=blue]As[/COLOR] System.[COLOR=#2b91af]Object[/COLOR], [COLOR=blue]ByVal[/COLOR] e [COLOR=blue]As[/COLOR] System.[COLOR=#2b91af]EventArgs[/COLOR]) [COLOR=blue]Handles[/COLOR] TBoxInThroatDiam.TextChanged
[COLOR=green]'For Changes made to Intake Throat Diameter[/COLOR]
[COLOR=blue]Dim[/COLOR] incount = Val([COLOR=blue]Me[/COLOR].TBoxInValveCount.Text) [COLOR=green]' Quantity of valves[/COLOR]
[COLOR=blue]Dim[/COLOR] inthroatdiam = Val([COLOR=blue]Me[/COLOR].TBoxInThroatDiam.Text) [COLOR=green]' Throat Diameter[/COLOR]
[COLOR=blue]Dim[/COLOR] inthroatarea = [COLOR=blue]CDbl[/COLOR](inthroatdiam * inthroatdiam * 0.7854)
[COLOR=blue]If[/COLOR] TBoxInValveDiam.Text = ([COLOR=#a31515]""[/COLOR]) [COLOR=blue]Then[/COLOR]
[COLOR=blue]Exit Sub[/COLOR]
[COLOR=blue]Else[/COLOR]
[COLOR=blue]For[/COLOR] [COLOR=blue]Each[/COLOR] r [COLOR=blue]As[/COLOR] [COLOR=#2b91af]DataGridViewRow[/COLOR] [COLOR=blue]In[/COLOR] [COLOR=blue]Me[/COLOR].DGV1.Rows
[COLOR=blue]If[/COLOR] r.Cells(11).Value = [COLOR=#a31515]"Intake"[/COLOR] [COLOR=blue]Then[/COLOR]
[COLOR=green]'Populates Calculated Throat Velocity using formula CTV = (CFM / throat area) * 2.14 / count[/COLOR]
r.Cells(8).Value = (Val(r.Cells(2).Value) / inthroatarea) * 2.14 / incount
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]Next[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]