Skip to main content

Function in VB.NET | Returning from a Function in VB.NET.

DESCRIPTION:
four textboxes for accepting numbers and three option buttons to select two,three or four. Design function adds to find addition of numbers selected using option buttons.
PROPERTIES:
RadioButton1
TextTwo
RadioButton2
TextThree
RadioButton3
TextFour
Button1
TextCLEAR
CODEING:
Public Class Form1
    Dim ANS As Integer
    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged,TextBox4.TextChanged,RadioButton1.CheckedChanged, RadioButton2.CheckedChanged, RadioButton3.CheckedChanged
        If RadioButton1.Checked And IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then
            Label1.Text = "ANS : " & ADD(Val(TextBox1.Text), Val(TextBox2.Text), 0, 0)
        ElseIf RadioButton2.Checked And IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) And IsNumeric(TextBox3.Text) Then
            Label1.Text = "Ans :" & ADD(Val(TextBox1.Text), Val(TextBox2.Text), Val(TextBox3.Text), 0)
        ElseIf RadioButton3.Checked And IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) And IsNumeric(TextBox3.Text) And IsNumeric(TextBox4.Text) Then
            Label1.Text = "Ans :" & ADD(Val(TextBox1.Text), Val(TextBox2.Text), Val(TextBox3.Text), Val(TextBox4.Text))
        ElseIf RadioButton1.Checked Or RadioButton2.Checked Or RadioButton3.Checked Then
            Label1.Text = "Fill in the Boxes With Number..."
        End If
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
    End Sub
    Function ADD(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal d As Integer) As String
        Return a + b + c + d
    End Function
End Class
DESIGNING:



Comments