12. list view


 

form1.vb

Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim str(2) As String

        Dim itm As ListViewItem

        str(0) = TextBox1.Text  'Accept value from the user.

        str(1) = TextBox2.Text

        itm = New ListViewItem(str)

        ListView1.Items.Add(itm) 'Add the items into the ListView

        TextBox1.Clear()

        TextBox2.Clear()

 

    End Sub

End Class

15 Design a secure login page using ASP.NET with username and password fields. Implement authentication to verify user credentials.





Default.aspx.vb

 

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>login page</title>

    <link rel="stylesheet" type="text/css" href="styles.css"/>

</head>

<body>

    <form id="form1" runat="server">

        <div class="login-container">

            <h2>Login</h2>

 

            <div class="input-group">

                <label for="txtUsername">Username:</label>

                <asp:TextBox ID="txtUsername" runat="server" CssClass="form-control"></asp:TextBox>

            </div>

 

            <div class="input-group">

                <label for="txtPassword">Password:</label>

                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" CssClass="form-control"></asp:TextBox>

            </div>

 

            <div class="input-group">

                <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" CssClass="btn btn-primary" />

            </div>

        </div>

    </form>

</body>

</html>

 

Default.aspx

Partial Class _Default

    Inherits System.Web.UI.Page

 

    Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click

        Dim username As String = txtUsername.Text

        Dim password As String = txtPassword.Text

 

        ' Validate user credentials (Replace this with your authentication logic)

        If ValidateUser(username, password) Then

            ' Authentication successful, redirect to a secure page

 

            'FormsAuthentication.RedirectFromLoginPage(username, False)

            Response.Write("welcome")

 

        Else

            ' Authentication failed, display an error message

            Response.Write("Invalid username or password")

        End If

    End Sub

    Private Function ValidateUser(username As String, password As String) As Boolean

        ' Add your authentication logic here

        ' For simplicity, we are using a hardcoded username and password

        Return username.ToLower() = "admin" AndAlso password = "password"

    End Function

End Class


8 Windows Form to open and view images with rotate features


 



Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim rotate As Image = New Bitmap(PictureBox1.Image)

        rotate.RotateFlip(RotateFlipType.Rotate90FlipNone)

        PictureBox1.Image = rotate

    End Sub

 

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim rotate As Image = New Bitmap(PictureBox1.Image)

        rotate.RotateFlip(RotateFlipType.Rotate270FlipNone)

        PictureBox1.Image = rotate

    End Sub

 

 

End Class

3. Create a console application that uses a For-Each loop to iterate through an array of strings and displays each element.



Module Module1

    Sub Main()

        ' Declare and initialize an array of strings

        Dim myArray() As String = {"Apple", "Banana", "Orange", "Grapes"}

 

        ' Use a For-Each loop to iterate through the array

        For Each fruit As String In myArray

            ' Display each element

            Console.WriteLine(fruit)

        Next

 

        ' Wait for user input before closing the console window

        Console.WriteLine("Press any key to exit...")

        Console.ReadKey()

    End Sub

End Module