Prince
Prince
For i = 0 To arr.Count - 1
ans += arr(i)
Next
' MsgBox("answer:" & ans)
P a g e 1 | 16
Sanepara Prince Div - d Rooll no -37
2. VB.Net program to find the largest element from the array of integers.
Public Class largest_02
Private Sub btnprint_Click(sender As Object, e As EventArgs) Handles btnprint.Click
Dim arr(5) As Integer
Dim large As Integer = 0
arr(0) = 1
arr(1) = 2
arr(2) = 30
arr(3) = 4
arr(4) = 5
For i = 0 To arr.Count - 1
P a g e 2 | 16
Sanepara Prince Div - d Rooll no -37
3. VB.Net program to find the EVEN numbers from the array of integers.
Public Class Even_03
Private Sub btnprint_Click(sender As Object, e As EventArgs) Handles btnprint.Click
P a g e 3 | 16
Sanepara Prince Div - d Rooll no -37
4. VB.Net program to find the second largest elements from the array of integers.
Public Class Second_largest_04
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim arr(5) As Integer
Dim first As Integer
Dim second As Integer
arr(0) = 1
arr(1) = 2
arr(2) = 30
arr(3) = 4
arr(4) = 7
For i = 0 To arr.Count - 1
If (first < arr(i)) Then
second = first
first = arr(i)
ElseIf (second < arr(i)) Then
second = arr(i)
P a g e 4 | 16
Sanepara Prince Div - d Rooll no -37
End If
Next
End Sub
P a g e 6 | 16
Sanepara Prince Div - d Rooll no -37
End Class
P a g e 7 | 16
Sanepara Prince Div - d Rooll no -37
End Class
If CheckBox1.Checked Then
Fruits.Add("apple")
End If
If CheckBox2.Checked Then
Fruits.Add("orange")
End If
P a g e 8 | 16
Sanepara Prince Div - d Rooll no -37
If CheckBox3.Checked Then
Fruits.Add("Guava")
End If
P a g e 9 | 16
Sanepara Prince Div - d Rooll no -37
BackColor = Color.Green
End Sub
End Class
10.VB.Net program to add item from ComboBox to ListBox and sort ListBox
items.
Public Class ComboBox_to_ListBox_10
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ComboBox1.Items.Add(TextBox1.Text)
End Sub
P a g e 10 | 16
Sanepara Prince Div - d Rooll no -37
End Class
P a g e 11 | 16
Sanepara Prince Div - d Rooll no -37
Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles
CheckBox3.CheckedChanged
BackColor = Color.Blue
ForeColor = Color.Red
End Sub
End Class
TreeView1.Nodes.Add(nodeText)
Else
TreeView1.SelectedNode.Nodes.Add(nodeText)
End If
P a g e 12 | 16
Sanepara Prince Div - d Rooll no -37
End Sub
13.VB.Net program to create a link that open Google in default browser using
LinkLabel.
Public Class LinkLabel_13
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs)
Handles LinkLabel1.LinkClicked
Process.Start("https://www.google.com/")
'ProcessStartInfo.WorkingDirectory
End Sub
P a g e 13 | 16
Sanepara Prince Div - d Rooll no -37
End Class
14. VB.Net program to set custom mask for contact number (Data Format-91-
1234567896) in MaskedTextBox.
Public Class Maskestextbox_14
Private Sub MaskedTextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles
MaskedTextBox1.KeyPress
If Not Char.IsControl(e.KeyChar) Then
If MaskedTextBox1.Text.Length = 0 Then
MaskedTextBox1.Text = "91-"
MaskedTextBox1.SelectionStart = MaskedTextBox1.Text.Length
ElseIf MaskedTextBox1.Text.Length = 3 Then
MaskedTextBox1.Text += "-"
MaskedTextBox1.SelectionStart = MaskedTextBox1.Text.Length
ElseIf MaskedTextBox1.Text.Length = 8 Then
MaskedTextBox1.Text += "-"
MaskedTextBox1.SelectionStart = MaskedTextBox1.Text.Length
End If
P a g e 14 | 16
Sanepara Prince Div - d Rooll no -37
End If
End Sub
End Sub
End Class
P a g e 16 | 16