If the column in question is intended to store currency values, it is better to use this type of data ( Currency or Currency or Decimal ) instead of Double
.
The error is not due to that detail, which is only intended as a tip for better programming.
The problem is because the regional settings are different between the operating system and the user.
In this case, the operating system expects the user to use the comma as a decimal separator. But the user is placing the point.
What we can do, in addition to properly instructing users, is to order our software to correct the data they enter.
We can build on an example of the msdn to make the following solution:
Private Sub DataGridView1_CellParsing(sender As Object, e As System.Windows.Forms.DataGridViewCellParsingEventArgs) Handles DataGridView1.CellParsing
If e IsNot Nothing Then
If Me.DataGridView1.Columns(e.ColumnIndex).Name.ToUpper = "PREMIO" Then
If e.Value IsNot Nothing Then
Try
' Obtiene el valor que introdujo el usuario '
Dim valor$ = e.Value.ToString
' Reemplaza el punto por la coma, y convierte a Double '
' Es muy importante aquí la conversión explícita, porque la implícita no funcionará '
e.Value = CDbl(valor.Replace(".", ","))
' Indica que el evento ha sido manipulado por el programador '
e.ParsingApplied = True
Catch ex As FormatException
' En caso de error, no pudo haber corrección del valor '
e.ParsingApplied = False
End Try
End If
End If
End If
End Sub