0% found this document useful (0 votes)
38 views

Form1 Eventargs: "Are You Sure?" "Exit"

This document contains code for several Visual Basic .NET Windows Forms applications. It defines multiple classes with event handler subroutines for buttons that add/remove items from list and combo boxes, find items, clear fields, and exit applications. It also includes code to reverse and get digit count of numbers entered into text boxes.

Uploaded by

Ali Al- Hayrani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Form1 Eventargs: "Are You Sure?" "Exit"

This document contains code for several Visual Basic .NET Windows Forms applications. It defines multiple classes with event handler subroutines for buttons that add/remove items from list and combo boxes, find items, clear fields, and exit applications. It also includes code to reverse and get digit count of numbers entered into text boxes.

Uploaded by

Ali Al- Hayrani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Wk 11

Public Class Form1

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


Button1.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Clear()
TextBox1.Focus()
Label3.Text = ListBox1.Items.Count

End Sub

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


Button5.Click
Dim ex As DialogResult
ex = MessageBox.Show("ARE YOU SURE?", "EXIT", MessageBoxButtons.YesNo,
MessageBoxIcon.Question)
If ex = Windows.Forms.DialogResult.Yes Then
Application.Exit()
End If
End Sub

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


Button2.Click
Dim INDEX As Integer
INDEX = ListBox1.SelectedIndex
If INDEX >= 0 Then
ListBox1.Items.RemoveAt(INDEX)
Label3.Text = ListBox1.Items.Count
Else
MsgBox("ENTER ITEMS IN THE LIST")

End If
End Sub

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


Button4.Click
If ListBox1.Text <> "" Then
ListBox1.Items.Clear()
Else
MsgBox("LISTBOX IS EMPTY", vbInformation + vbOKOnly)
End If
End Sub

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


Button3.Click
Dim I As Integer
For I = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(I) = TextBox2.Text Then
MsgBox("NAME FOUND")
TextBox2.Clear()
TextBox2.Focus()
Exit Sub
End If
Next
MsgBox("NAME NOT FOUND")

End Sub
End Class
Wk11

Public Class Form1

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


Button2.Click
Dim INDEX As Integer
INDEX = ComboBox1.SelectedIndex
If INDEX >= 0 Then
ComboBox1.Items.RemoveAt(INDEX)
Label4.Text = ComboBox1.Items.Count
Else
MsgBox("ENTER ITEMS IN THE LIST")

End If
End Sub

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


Button4.Click
Dim ex As DialogResult
ex = MessageBox.Show("ARE YOU SURE?", "EXIT", MessageBoxButtons.YesNo,
MessageBoxIcon.Question)
If ex = Windows.Forms.DialogResult.Yes Then
Application.Exit()
End If
End Sub

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


Button3.Click
If ComboBox1.Text <> "" Then
ComboBox1.Items.Clear()
Label4.Text = ComboBox1.Items.Count
Else
MsgBox("COMBOBOX IS EMPTY", vbInformation + vbOKOnly)
End If
End Sub

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


Button1.Click
ComboBox1.Items.Add(TextBox1.Text)
Label4.Text = ComboBox1.Items.Count
TextBox1.Clear()
TextBox1.Focus()

End Sub
End Class

Wk12

Public Class Form1

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


Button3.Click
Dim ex As DialogResult
ex = MessageBox.Show("ARE YOU SURE?", "EXIT", MessageBoxButtons.YesNo,
MessageBoxIcon.Question)
If ex = Windows.Forms.DialogResult.Yes Then
Application.Exit()
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Focus()
End Sub

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


Button1.Click
Dim num As Integer
Dim remain As Integer
Dim rev_remain As Integer
num = Integer.Parse(TextBox1.Text)
Do While num <> 0
remain = num Mod 10
rev_remain = rev_remain * 10 + remain
num = num / 10
Loop
TextBox2.Text = rev_remain.ToString
End Sub

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


Button4.Click
Dim num As Integer
Dim count As Integer
count = 0
num = Integer.Parse(TextBox1.Text)
Do While num <> 0
num = num / 10
count = count + 1
Loop
TextBox2.Text = count.ToString
End Sub
End Class

You might also like