Download Unit 14: Event-Driven Programming
Transcript
Unit 14: Event-Driven Programming
BTEC Extended Diploma for IT Practitioners (Software Development)
advancing learning, changing lives
Example programs – 10. Using TabControls
Lecturer: Jane Fletcher
Coding for the program
Public Class Form2
Dim decNumber As Decimal
'the holder of the number
Dim intNumberOfDecimalPlaces As Integer
Private Sub btnEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnEnd.Click
'Stop the project
Me.Close()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnClear.Click
'Clear out the rubbish
lstOutput.Items.Clear()
txtNumber.Text = ""
txtNumber.Focus()
End Sub
Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnProcess.Click
'Take the value entered in the text box, validate it and display it
'in different ways.
If txtNumber.Text.Length = 0 Then
MsgBox("You must enter something for number!", MsgBoxStyle.Critical, _
"No entry made for number!")
txtNumber.Focus()
Exit Sub
End If
If txtNumber.Text.Length > 10 Then
MsgBox("You have entered too much information in number!", MsgBoxStyle.Critical, _
"Too long an entry for number!")
txtNumber.Text = ""
txtNumber.Focus()
Exit Sub
End If
If Not IsNumeric(Val(txtNumber.Text)) Then
MsgBox("You must enter a number!", MsgBoxStyle.Critical, "Not numeric!")
txtNumber.Text = ""
txtNumber.Focus()
Exit Sub
End If
decNumber = Val(txtNumber.Text)
If txtDecimalPlaces.Text.Length = 0 Then
MsgBox("You must enter something!", MsgBoxStyle.Critical, _
"No entry made for number of decimal places!")
txtDecimalPlaces.Focus()
Exit Sub
End If
© Jane Fletcher, South Nottingham College
179