Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Public Class Form1

Dim no1, no2, result As Integer


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
no1 = TextBox1.Text
no2 = TextBox2.Text
swap(no1, no2)
MsgBox(" After swap call by value no1=" & no1 & " No2=" & no2)
swapref(no1, no2)
MsgBox(" After swap call by reference no1=" & no1 & " No2=" & no2)
End Sub
Sub swap(ByVal x As Integer, ByVal y As Integer)
Dim temp As Integer
temp = x ' save the value of x
x = y ' put y into x
y = temp 'put temp into y

End Sub

Sub swapref(ByRef x As Integer, ByRef y As Integer)


Dim temp As Integer
temp = x ' save the value of x
x = y ' put y into x
y = temp 'put temp into y
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles


Button4.Click
no1 = TextBox1.Text
TextBox2.Text = factorial(no1)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
no1 = TextBox1.Text
no2 = TextBox2.Text
TextBox3.Text = MaxNo(no1, no2)
End Sub
Public Function MaxNo(ByVal a As Integer, ByVal b As Integer) As Integer
If (a > b) Then
Return a
Else
Return b
End If
End Function

Function factorial(ByVal m As Integer) As Integer


If m = 0 Then
Return 1
Else
Return m * factorial(m - 1)
End If
End Function
End Class

You might also like