Public Function StdFormSave() As Integer
Dim returnValue As Integer = 0
Dim startRow As Integer
Dim endRow As Integer
startRow = 0
endRow = ThisForm.PrimaryIDOCollection.GetNumEntries - 1
For i As Integer = startRow To endRow
'NOTE: a new row will return TRUE for both IsObjectNew and IsObjectModified
If (ThisForm.PrimaryIDOCollection.IsObjectModified(i) = True) Then
Dim item As String = ThisForm.PrimaryIDOCollection.GetObjectProperty("Item", i)
If (IsStringValid(item, False) = False) Then
Application.ShowMessage(String.Format("Item {0} has spaces or special characters.", item))
returnValue = -1
Exit For
End If
End If
Next
Return returnValue
End Function
Private Function IsStringValid(s As String, allowSpaces As Boolean) As Boolean
Dim isValid As Boolean = True
Dim lowerRange As Integer = 32
' set lower range for the function check
If allowSpaces = False Then
lowerRange = 33
End If
For Each c As Char In s
' do not allow pipe |
If (AscW(c) < lowerRange OrElse AscW(c) > 126 OrElse AscW(c) = 124) Then
isValid = False
Exit For
End If
Next
Return isValid
End Function
Comments