If you do a lot of importing of files and do not have control over what the user puts in i.e. long names passed the field width of the DB or Textbox, This could be imports from a CSV or spreadsheet then try validating the field length.
The following VB Function takes the string and the field length truncates the string and returns it.
Private Function truncate(mystring As String, mylength As Int16)
If mystring.Length >= mylength - 1 Then
mystring = mystring.Substring(0, mylength - 1)
End If
Return mystring
End Function
No comments:
Post a Comment