This document contains the code for a Visual Basic .NET Windows Forms application that demonstrates various mathematical functions and operations. It includes subs and functions to:
1) Swap two integers passed by value or reference and display the results.
2) Calculate the Fibonacci sequence up to a given limit and display the results.
3) Reverse an integer entered in a text box and display the result.
4) Calculate the factorial of an integer entered in a text box and display the result.
This document contains the code for a Visual Basic .NET Windows Forms application that demonstrates various mathematical functions and operations. It includes subs and functions to:
1) Swap two integers passed by value or reference and display the results.
2) Calculate the Fibonacci sequence up to a given limit and display the results.
3) Reverse an integer entered in a text box and display the result.
4) Calculate the factorial of an integer entered in a text box and display the result.
This document contains the code for a Visual Basic .NET Windows Forms application that demonstrates various mathematical functions and operations. It includes subs and functions to:
1) Swap two integers passed by value or reference and display the results.
2) Calculate the Fibonacci sequence up to a given limit and display the results.
3) Reverse an integer entered in a text box and display the result.
4) Calculate the factorial of an integer entered in a text box and display the result.
This document contains the code for a Visual Basic .NET Windows Forms application that demonstrates various mathematical functions and operations. It includes subs and functions to:
1) Swap two integers passed by value or reference and display the results.
2) Calculate the Fibonacci sequence up to a given limit and display the results.
3) Reverse an integer entered in a text box and display the result.
4) Calculate the factorial of an integer entered in a text box and display the result.
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 by 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
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
no1 = TextBox1.Text Fibonacci(no1) 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 Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim r As Integer TextBox2.Text = Reverse(r) End Sub
Sub Fibonacci(ByVal limit As Integer)
Dim n1 As Integer Dim n2 As Integer Dim result As String = "" n1 = 1 n2 = 1 result = n1 While n2 < limit result = result & " " & n2 n2 = n2 + n1 n1 = n2 - n1 End While MsgBox("Fibonacci =" & result) End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click no1 = TextBox1.Text TextBox2.Text = factorial(no1) End Sub
Public Function Reverse(rn As Integer)
Dim numbers = Val(TextBox1.Text) Dim result As Integer While numbers > 0 rn = numbers Mod 10 result = result * 10 + rn numbers = numbers \ 10 End While Reverse = result 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