Page 132 - TCS ICT Book 8
P. 132
The City School 2021-2022
Event Handling
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
End Sub
Private Sub Form1_MouseHover(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.MouseHover
MsgBox(“This window pop-up window appears when mouse is hovered
over the button”)
End Sub
End Class
Functions and Subroutines
Public Class Form1
Private Function BMI(ByVal Height As Single, ByVal weight As Single)
As Double
BMI = weight / Height ^ 2
End Function
Private Sub btnBMI_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBMI.Click
Dim h As Single
Dim w As Single
h = Val(TextBox1.Text)
w = Val(TextBox2.Text)
lblBMIResult.Text = BMI(h, w)
End Sub
End Class
132

