Friday, August 19, 2005

Checking our UserForm info

Even though we're making it sooo easy for the users of our Excel applications by providing custom UserForms, we still can't be too sure exactly what information will be entered!

Time to find out how we can use the power of VBA to help our users enter valid information (a.k.a. - Input Validation). We'll do this by combining IF statements with MsgBox statements. Here's a sample to start us off:

Sub cmdOK_click()

'First check to see whether valid info was entered!
If txtFirstName = "" Then

MsgBox("Please enter your first name")
Exit Sub

End If

End Sub

Have a go at adding some input validation to your StudentResults Excel application - we'll gradually build this up with more functionality (such as making sure a number is entered, or putting the cursor back in the right spot on our UserForm for the user).

Once you're done, you're ready to finish Band Scenario 5!

0 Comments:

Post a Comment

<< Home