I want users to enter their name into a textbox but i want to ensure that they type in something so my program will continue the name into another form by a button. How do foolproof this while clicking the button won't automatically send nothing to the other form and end up crashing?

Add validation either client- or server-side to check the value of the textbox before proceeding. If the length of the input is too short or non-existent then stop and inform the user.

You'll want to use something like:

If Not TextBox1.Text.IsNullOrWhiteSpace() Then
    ' Allow processing of text entered
    MessageBox.Show("Please enter information in the text box before proceeding!")
End If

Just place:

If TextBox.Text <> "" or TextBox1.Text <> String.Empty Then
    'Place code here'
    MsgBox("Please enter a valid name.")
    e.Cancel = True
End If

Better question...Does each user have an active directory login and are they using this login to launch the application?

Edited 4 Years Ago by Begginnerdev

Edit to last post

e.Cancel = True

Will only work with certain event arg types.

Return 'For a sub'
Return Nothing 'For a function'
'I recommend returning the value that is checked against.'

If MyFunction(0) = True Then

End If

Private Function MyFunction(ByVal myVal as Integer)
    If MyVal > 1 Then
        Return True
        Return False
    End If
End Function

Use these in those cases

Edited 4 Years Ago by Begginnerdev

This article has been dead for over six months. Start a new discussion instead.