Checking the Empty Objects Before Saving Data
Some times empty data making problem during saving in the database. so this funtion ensure the object value is empty or not.
This is VB6 Code. You can also use in VB.Net with small Change by imports System.visual Basic Namespace
here passing the form name and list of object name seperated by comma. if found empty object this function return true with Object name otherwise return False value.
public Function WithEmptyObject(frm As Form, ParamArray Ctrls()) As Boolean
Dim Ctrl, rv As Boolean
rv = False
For Each Ctrl In Ctrls
If Len(Trim(frm.Controls(Ctrl).Text)) = 0 Then
If frm.Controls(Ctrl).Enabled Then frm.Controls(Ctrl).SetFocus
MsgBox frm.Controls(Ctrl).Tag & " must not contain null value.", vbInformation, "Required Entry"
rv = True
Exit For
End If
Next
WithEmptyObject = rv
Set Ctrl = Nothing
End Function