Created
May 12, 2013 01:21
-
-
Save shahrulnizam/5562035 to your computer and use it in GitHub Desktop.
VB Lesson: Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class Form1 | |
Dim num1 As Integer | |
Dim num2 As Integer | |
Private Function copy() | |
num1 = TextBox1.Text | |
num2 = TextBox2.Text | |
End Function | |
Private Function add(ByVal a As Integer, ByVal b As Integer) | |
Return num1 + num2 | |
End Function | |
Private Function subtract(ByVal a As Integer, ByVal b As Integer) | |
Return num1 - num2 | |
End Function | |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click | |
copy() | |
Label1.Text = add(num1, num2) | |
End Sub | |
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click | |
copy() | |
Label1.Text = subtract(num1, num2) | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment