Public Class Form10
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a(5) As Double
Dim item As Double
Dim i As Integer
For i = 1 To 5
a(i) = InputBox("Enter 5 Elements")
Next
item = InputBox("Which Elements you want ")
For i = 1 To 5
If a(i) = item Then
MsgBox(item & " Found at Position " & i)
Exit For
End If
Next
If i = 6 Then
MsgBox(item & "Does not Exist ")
End If
End Sub
End Class
Program 17 Combo box Tools
Coding for Form Load
Public Class Form13
Private Sub Form13_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = "MLC KORBA"
End Sub
Coding for >> Button1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.SelectedIndex > -1 Then
Dim sidx As Integer
sidx = ComboBox1.SelectedIndex
Dim sitem As Object
sitem = ComboBox1.SelectedItem
ListBox1.Items.Add(sitem)
End If
End Sub
Coding for Sort Button3
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ComboBox1.Sorted = True
End Sub
Coding for Clear Button4
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
ListBox1.Items.Clear()
End Sub
Coding for Fill Button2
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ComboBox1.Items.Clear()
ComboBox1.Items.Add("Gardening")
ComboBox1.Items.Add("Reading")
ComboBox1.Items.Add("Dancing")
ComboBox1.Items.Add("Music")
ComboBox1.Items.Add("Watching TV")
ComboBox1.Text = "Selected List...."
End Sub
Coding for combobox1
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Label2.Text = ComboBox1.SelectedIndex.ToString()
End Sub
End Class
Program 18 Checklistbox Tool
Coding for Form Load
Public Class Form17
Private Sub Form17_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = "MLC KORBA"
CheckedListBox1.Items.Add("DCA")
CheckedListBox1.Items.Add("PGDCA")
CheckedListBox1.Items.Add("BCA")
CheckedListBox1.Items.Add("Tally")
Label1.Text = "Choose one or more Courses "
Button1.Text = "Select"
Button2.Text = "Exit"
End Sub
Coding for Button1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ch As New System.Text.StringBuilder
dim item as object
For Each item In CheckedListBox1.CheckedItems
ch.Append(item)
ch.Append(" ")
Next
MessageBox.Show("Your Selected Items " & ch.ToString())
End Sub
Coding for Button2
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
Program 19Public Class Form17
Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
Label1.Text = HScrollBar1.Value.ToString
End Sub
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
Label2.Text = VScrollBar1.Value.ToString
End Sub
End Class
Program 20Public Class Form18
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dp As Date = DateTimePicker1.Value
Dim dp1 As Date = DateTimePicker2.Value
Dim result As TimeSpan = dp.Subtract(dp1)
Dim ds As Integer = result.TotalDays
TextBox1.Text = ds
TextBox1.ForeColor = Color.Red
MsgBox("Days=" & ds)
End Sub
End Class
Program 21
Public Class Form19
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox2.Image = PictureBox1.Image
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PictureBox1.Visible = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
PictureBox1.Visible = True
End Sub
End Class
Public Class Form20
Coding For New
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
If RichTextBox1.Modified Then
Dim a As MsgBoxResult
a = MsgBox("Do you want to changes ", MsgBoxStyle.YesNoCancel, "New Document")
If a = MsgBoxResult.No Then
RichTextBox1.Clear()
ElseIf a = MsgBoxResult.Cancel Then
ElseIf MsgBoxResult.Yes Then
SaveFileDialog1.ShowDialog()
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
RichTextBox1.Clear()
End If
Else
RichTextBox1.Clear()
End If
End Sub
Coding for Open
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
If RichTextBox1.Modified Then
Dim ask As MsgBoxResult
ask = MsgBox("Do You want to Save the file ", MsgBoxStyle.YesNoCancel, "OPen Document")
If ask = MsgBoxResult.No Then
OpenFileDialog1.ShowDialog()
RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
ElseIf ask = MsgBoxResult.Cancel Then
ElseIf ask = MsgBoxResult.Yes Then
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
RichTextBox1.Clear()
End If
Else
OpenFileDialog1.ShowDialog()
Try
RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
Catch ex As Exception
End Try
End If
End Sub
Coding for Save
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
SaveFileDialog1.ShowDialog()
If My.Computer.FileSystem.FileExists(SaveFileDialog1.FileName) Then
Dim ask As MsgBoxResult
ask = MsgBox("File already exist you like to replace it ", MsgBoxStyle.YesNoCancel, "File Exist")
If ask = MsgBoxResult.No Then
SaveFileDialog1.ShowDialog()
If ask = MsgBoxResult.Yes Then
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
End If
Else
Try
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
Catch ex As Exception
End Try
End If
End If
End Sub
Coding for Exit
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
Me.Close()
End Sub
Coding for Cut
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
RichTextBox1.Cut()
End Sub
Coding for Paste
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
RichTextBox1.Paste()
End Sub
Coding for Copy
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
RichTextBox1.Copy()
End Sub
Coding for Undo
Private Sub CopyToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem1.Click
RichTextBox1.Undo()
End Sub
Coding for Redo
Private Sub PasteToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem1.Click
RichTextBox1.Redo()
End Sub
Coding for Font
Private Sub FontToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem1.Click
FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font
End Sub
Coding for Fore Color
Private Sub ForeColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ForeColorToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.ForeColor = ColorDialog1.Color
End Sub
Coding for Left Alignment
Private Sub LeftToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
RichTextBox1.SelectionAlignment = HorizontalAlignment.Left
End Sub
Coding for Right Alignment
Private Sub RightToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
RichTextBox1.SelectionAlignment = HorizontalAlignment.Right
End Sub
Coding for Center Alignment
Private Sub CenterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
RichTextBox1.SelectionAlignment = HorizontalAlignment.Center
End Sub
Private Sub YesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
RichTextBox1.SelectionBullet = True
End Sub
Private Sub NoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
RichTextBox1.SelectionBullet = False
End Sub
Coding for Zoom 2
Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
RichTextBox1.ZoomFactor = 2
End Sub
Coding for Zoom 4
Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click
RichTextBox1.ZoomFactor = 4
End Sub
Coding for Zoom 8
Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click
RichTextBox1.ZoomFactor = 8
End Sub
Coding for Zoom 10
Private Sub ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem5.Click
RichTextBox1.ZoomFactor = 10
End Sub
Coding for Back Color
Private Sub BackColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackColorToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.BackColor = ColorDialog1.Color
End Sub
Coding for Find
Private Sub FindToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindToolStripMenuItem1.Click
Dim a, b As String
a = InputBox("Enter text to Find ")
b = InStr(RichTextBox1.Text, a)
If b Then
RichTextBox1.SelectionStart = b - 1
RichTextBox1.SelectionLength = Len(a)
Else
MsgBox("Text not Found !!")
End If
End Sub
End Class