Set Error(Loan Text Box, _ "Please enter a loan amount greater than 0 " & _ "in numeric characters.") e. Cancel = False End If End Sub Private Sub Rate Combo Box_Selected Index Changed(By Val sender As System. The example code uses "Text Box1" and "Combo Box1" rather than the names of the controls you're actually using. | MSDN Data Walkthroughs VBForums Database Development FAQ My Code Bank Submissions: VB | C# My Blog: Data Among Multiple Forms (3 parts) Beginner Tutorials: VB | C# | SQLAll you need to do is change the names used in the Handles clauses to the names of your controls. How many places in the code do the words "Handles", "Text Box1" and "Combo Box1" appear?
C:\Users\Ju\Desktop\Desc 381 Ass3\Exercise 36 122 Loan Application All you need to do is change the names used in the Handles clauses to the names of your controls.
Although if the users takes focus of the field, the "bad" data (such as "fdgfdg") is still left in the field. Additionally, youre performing validation in the wrong events. Set Error(Rate Combo Box, "") If Not Is Numeric(Loan Text Box. Set Error(Rate Combo Box, "") If Not Is Numeric(Rate Combo Box. Set Error(Rate Combo Box, _ "Please choose or enter an interest rate " & _ "between 2 and 12 in numeric characters.") e. Text The reason why this isnt working is because youre trying to use the Cancel property for the Event Args class. So could some demonstrate how when focus is lost on the field, if the data is not valid, a default value will be entered instead e.g.5 if you are hand-rolling validation like you do here, all you need to do is to set the default value after you Message Box.
Of course, if it happened to actually be a different type that had been cast to Event Args, then you could cast it back, but in this case that will not work.