With the code below Im getting NullException with the If statements. Where If the user enters nothing "" then the
message box shows. Any Idea's what Im doing wrong?
Code:Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click Dim sUserID As String Dim sPass As String If sUserID.Trim() = "" Then MessageBox.Show("UserID cannot be blank," _ & "Please endter a proper UserID.", "Error", _ MessageBoxButtons.OK, MessageBoxIcon.Error) txtUserID.Select() Else If sPass.Trim() = "" Then MessageBox.Show("Password cannot be blank," _ & "Please enter a proper password.", "Error", _ MessageBoxButtons.OK, MessageBoxIcon.Error) txtPass.Select() Else Me.DialogResult = DialogResult.OK End If End If End Sub




Reply With Quote