TY BCA Sem.6 Practical 1 to 5 Solution



Practical 1: Display message and current date and time using Label Control.
HTML CODE:-
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Practical1.aspx.vb" Inherits="US06CBCA01_Practicals.Practical1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Label ID="Label1" runat="server"></asp:Label>
            <br />
            <asp:Label ID="Label2" runat="server"></asp:Label>
        </div>
    </form>
</body>
</html>

VB Code:-
Public Class Practical1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label1.Text = "Hello World!"
        Label2.Text = System.DateTime.Now.ToString
    End Sub

End Class
Practical2: Display the message in Label using name typed in Textbox.
HTML CODE:-
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Practical2.aspx.vb" Inherits="US06CBCA01_Practicals.Practical2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
            align-content :center ;
            text-align :center ;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
    <table class="auto-style1">
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text="Enter Your Name:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button ID="Button1" runat="server" Text="Clilck" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label2" runat="server"></asp:Label>
            </td>
            <td>&nbsp;</td>
        </tr>
    </table>
   
        </div>
    </form>
</body>
</html>

VB Code:-
Public Class Practical2
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label2.Text = "Hello " + TextBox1.Text+ ”…….!!!”
        TextBox1.Text = ""
    End Sub
End Class


Practical3: Perform Arithmetic Operation.
HTML CODE:-
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Practical3.aspx.vb" Inherits="US06CBCA01_Practicals.Practical3" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Practical3</title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
    <table class="auto-style1">
        <tr>
            <td colspan="2">
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            </td>
            <td colspan="2">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
            </td>
            <td colspan="2">
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Button ID="Button1" runat="server" Text="Button" />
            </td>
            <td>
                <asp:Button ID="Button2" runat="server" Text="Button" />
            </td>
            <td>
                <asp:Button ID="Button3" runat="server" Text="Button" />
            </td>
            <td>
                <asp:Button ID="Button4" runat="server" Text="Button" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
            </td>
            <td colspan="2">
                <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
            </td>
        </tr>
    </table>
        </div>
    </form>
</body>
</html>

VB Code:-
Public Class Practical3
    Inherits System.Web.UI.Page
    Dim a, b, c As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label1.Text = "No. 1:"
        Label2.Text = "No. 2:"
        Label3.Text = "Answer:"
        Button1.Text = "+"
        Button2.Text = "-"
        Button3.Text = "*"
        Button4.Text = "/"
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        c = a + b
        TextBox3.Text = c.ToString

    End Sub
    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        c = a - b
        TextBox3.Text = c.ToString

    End Sub
    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        c = a * b
        TextBox3.Text = c.ToString

    End Sub
    Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        c = a / b
        TextBox3.Text = c.ToString

    End Sub
End Class
Practical4: Perform numeric operation according to user selection of radio buttons.
HTML CODE:-
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Practical4.aspx.vb" Inherits="US06CBCA01_Practicals.Practical4" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
            text-align :center;
        }
        .auto-style2 {
            height: 14px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>

            <table class="auto-style1">
                <tr>
                    <td>
                        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:RadioButton ID="RadioButton1" runat="server" GroupName="opt" />
                        <br />
                        <asp:RadioButton ID="RadioButton2" runat="server" GroupName="opt" />
                        <br />
                        <asp:RadioButton ID="RadioButton3" runat="server" GroupName="opt" />
                        <br />
                        <asp:RadioButton ID="RadioButton4" runat="server" GroupName="opt" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button ID="Button1" runat="server" Text="Button" />
                    </td>
                </tr>
                <tr>
                    <td class="auto-style2">
                        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
                    </td>
                    <td class="auto-style2">
                        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                    </td>
                </tr>
            </table>

        </div>
    </form>
</body>
</html>

VB CODE:-
Public Class Practical4
    Inherits System.Web.UI.Page
    Dim a, b As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label1.Text = "Enter No. :"
        RadioButton1.Text = "Odd or Even"
        RadioButton2.Text = "Positive or Negative"
        RadioButton3.Text = "Square"
        RadioButton4.Text = "Factorial"
        Button1.Text = "Click"
        Label2.Text = "Answer is "
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        a = Val(TextBox1.Text)
        If RadioButton1.Checked Then
            If a Mod 2 = 0 Then
                TextBox2.Text = "No is Even."
            Else
                TextBox2.Text = "No is Odd."
            End If
        End If
        If RadioButton2.Checked Then
            If a > 0 Then
                TextBox2.Text = "No is Positive."
            Else
                TextBox2.Text = "No is Negative."
            End If
        End If
        If RadioButton3.Checked Then
            If a > 0 Then
                TextBox2.Text = (a * a).ToString
            End If
        End If
        If RadioButton4.Checked Then
            b = 1
            For i As Integer = a To 1 Step -1
                b *= i
            Next
            TextBox2.Text = b.ToString
        End If
    End Sub
End Class

Practical5: Perform string operation according to user selection of radio buttons.
HTML CODE:-
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Practical5.aspx.vb" Inherits="US06CBCA01_Practicals.Practical5" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Practical 5</title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
            text-align :center ;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>

            <table class="auto-style1">
                <tr>
                    <td>
                        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:RadioButton ID="RadioButton1" runat="server" GroupName="str" />
                        <br />
                        <asp:RadioButton ID="RadioButton2" runat="server" GroupName="str" />
                        <br />
                        <asp:RadioButton ID="RadioButton3" runat="server" GroupName="str" />
                        <br />
                        <asp:RadioButton ID="RadioButton4" runat="server" GroupName="str" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button ID="Button1" runat="server" Text="Button" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                    </td>
                </tr>
            </table>

        </div>
    </form>
</body>
</html>
VB.NET CODE:-
Public Class Practical5
    Inherits System.Web.UI.Page
    Dim str As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label1.Text = "Enter String:"
        RadioButton1.Text = "Uppercase"
        RadioButton2.Text = "Lowercase"
        RadioButton3.Text = "Right 5 Characters"
        RadioButton4.Text = "Left 5 Characters"
        Button1.Text = "Click"
        Label2.Text = "Output"
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If RadioButton1.Checked Then
            TextBox2.Text = TextBox1.Text.ToUpper()
        End If
        If RadioButton2.Checked Then
            TextBox2.Text = TextBox1.Text.ToLower()
        End If
        If RadioButton3.Checked Then
            If TextBox1.Text.Length > 5 Then
                TextBox2.Text = TextBox1.Text.Substring(TextBox1.Text.Length - 5, 5)
            Else
                MsgBox("Can't Give output.")
            End If
        End If
        If RadioButton4.Checked Then
            If TextBox1.Text.Length > 5 Then
                TextBox2.Text = TextBox1.Text.Substring(0, 5)
            Else
                MsgBox("Can't Give output.")
            End If
        End If
    End Sub
End Class

Comments

Popular Posts