I posted this to the beginning
VB 2005 forum earlier today.
I'm posting it here in hopes that someone will be able to help me.
I need help!
I have been using Google, MSDN, and just about every developer forum I can find on the internet.
I am deliberately entering invalid data into my datagrid cell, but it still 'passes' 'validation'.
Can anyone explain what I am doing wrong?
Here's my code:
Code:
Public Class frmScanEquipmentIn
Private intPhoneIdentity As Integer
Private intNetworkID As Integer
Private strCellESN As String
Dim strConn As SqlConnection
Private APC_WirelessConnectionString As String = DBHandling.DetermineServer(strConn)
...
Private Sub dgvEquipment_CellValidated(ByVal sender As Object, _
ByVal e As DataGridViewCellEventArgs) _
Handles dgvEquipment.CellValidated
dgvEquipment.Rows(e.RowIndex).ErrorText = Nothing
End Sub
Private Sub dgvEquipment_CellLeave(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
Handles dgvEquipment.CellLeave
End Sub
Private Sub EquipmentValidationByCell(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellParsingEventArgs) _
Handles dgvEquipment.CellParsing
strCellESN = dgvEquipment.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
If dgvEquipment.Columns(e.ColumnIndex).Name = "ESNDataGridViewTextBoxColumn" Then
If EquipmentNumberValidation(strCellESN) Then
dgvEquipment.Rows(e.RowIndex).ErrorText = _
"Invalid ESN - please correct"
e.ParsingApplied = False
End If
End If
End Sub
...
Private Function EquipmentNumberValidation(ByRef strCellESN As String) As Boolean
Dim intStrLen As Integer = Len(strCellESN)
MsgBox("Value, Length of strCellESN: " & strCellESN & ", " & (CType(intStrLen, String)))
MsgBox("Value of intNetworkID: " & (CType(intNetworkID, String)))
Select Case intNetworkID
Case 1
Select Case Len(strCellESN)
Case 11
Case 18
Return True
Case Else
Return False
End Select
Case 4
Select Case Len(strCellESN)
Case 15
Return True
Case Else
Return False
End Select
Case Else
Return False
End Select
End Function
I would really appreciate the help. I have been working on this for 'days' and am getting more and more frustrated. (The upside is that I am learning a LOT about functions, events, properties, etc.)
I have figured out a couple more things since I posted this earlier today, I am now calling the validation routine. But, it calls it for the cell after - this makes no sense to me.
Can someone please explain this to me?
Thanks in advance.
Karen