Skip to content

Instantly share code, notes, and snippets.

@shahrulnizam
Created May 12, 2013 01:21
Show Gist options
  • Save shahrulnizam/5562035 to your computer and use it in GitHub Desktop.
Save shahrulnizam/5562035 to your computer and use it in GitHub Desktop.
VB Lesson: Function
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