Hi Nadya,
have a problem with the RadTextBox4.Text and RadTextBox5.Text, these should only numbers and commas
as input allow, example: "23,40 " .
Therefore, include the following code:
Private Sub RadTextBox4_KeyPress(sender As Object, e As KeyPressEventArgs) Handles RadTextBox4.KeyPress
'* This function only allows numeric and comma inputs!!
Const Numbers" = "0123456789, "
If Asc(e.KeyChar) <> 8 Then
If InStr(Numbers, Chr(Asc(e.KeyChar))) = 0 Then
e.Handled = True
Exit Sub
End If
End If
End Sub
Private Sub RadTextBox5_KeyPress(sender As Object, e As KeyPressEventArgs) Handles RadTextBox5.KeyPress
'* This function only allows numeric input!!
Const Numbers" = "0123456789, "
If Asc(e.KeyChar) <> 8 Then
If InStr(Numbers, Chr(Asc(e.KeyChar))) = 0 Then
e.Handled = True
Exit Sub
End If
End If
End Sub
Also works well, only I noticed that if the user accidentally after the two
comma enters another comma as here "23,40", then the program crashes off with
the following error code:
-System.InvalidCastException: "Invalid conversion from the string 23.40, to type Double."-
on this line "*"
For Each rowInfo In Me.RadGridView1.Rows
For each cellInfo as GridViewCellInfo in rowInfo.cells
If cellInfo.ColumnInfo.Name = "Document" Then
** --> If CDec(cellInfo.Value) >= RadTextBox4.Text And CDec(cellInfo.Value)
sum += CDec(cellInfo.Value)
End If
End If
Next
Next
Question:
Can I somehow intercept this or prevent it with another KeyPress event?