يا بسام،
هذه إحدى طريق، ويمكنك وضع الإجراء IsEmptyTextBox في Module ليكون متاح لأي Form
هذه إحدى طريق، ويمكنك وضع الإجراء IsEmptyTextBox في Module ليكون متاح لأي Form
PHP كود :
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If IsEmptyTextBox(TextBox1, "أدخل الإسم") Then Return
If IsEmptyTextBox(TextBox2, "أدخل التخصص") Then Return
If IsEmptyTextBox(TextBox3, "أدخل العنوان") Then Return
End Sub
' الأفضل يكون في موديول ليكون متاح لجميع الفورم '
Public Function IsEmptyTextBox(txtBox As TextBox, Optional alert As String = "أدخل قيمة") As Boolean
If txtBox.Text.Trim = "" Then
txtBox.Focus()
txtBox.BackColor = Color.MistyRose
MsgBox(alert)
Return True
Else
txtBox.BackColor = Nothing
Return False
End If
End Function