Hi everyone this is my first post
ok so i have a Datagridview called dgvPartsOrdered and im trying to validate the columns 3 and 4 (which r actually 2 and 3) to be only numeric. The default values of those cells are 0 which i set through the properties (i even formated it as number through the GUI). However, at run time, for some reason the system thinks that those cells are strings if they remain untouched by the user. here is my code
Dim v AsInteger = 0
DoWhile (v + 1) < dgvPartsOrdered.RowCount
IfNot IsNumeric(dgvPartsOrdered.Rows(v).Cells(2).Value) OrNot IsNumeric(dgvPartsOrdered.Rows(v).Cells(3).Value) Then
MsgBox("The inputs in the quantity fields may only contain numbers", vbExclamation, "Invalid Entry")
dgvPartsOrdered.Focus()
Exit Sub
EndIf
v = v + 1
Loop
I tryed putting the CInt(dgvPartsOrdered.Rows(v).Cells(2).Value) but that won't work because if the user inputs a letter it will crash.
I hope i was explicit enough. So is there anyway around this?
thanks
ok so i have a Datagridview called dgvPartsOrdered and im trying to validate the columns 3 and 4 (which r actually 2 and 3) to be only numeric. The default values of those cells are 0 which i set through the properties (i even formated it as number through the GUI). However, at run time, for some reason the system thinks that those cells are strings if they remain untouched by the user. here is my code
Dim v AsInteger = 0
DoWhile (v + 1) < dgvPartsOrdered.RowCount
IfNot IsNumeric(dgvPartsOrdered.Rows(v).Cells(2).Value) OrNot IsNumeric(dgvPartsOrdered.Rows(v).Cells(3).Value) Then
MsgBox("The inputs in the quantity fields may only contain numbers", vbExclamation, "Invalid Entry")
dgvPartsOrdered.Focus()
Exit Sub
EndIf
v = v + 1
Loop
I tryed putting the CInt(dgvPartsOrdered.Rows(v).Cells(2).Value) but that won't work because if the user inputs a letter it will crash.
I hope i was explicit enough. So is there anyway around this?
thanks