Public Class Form1
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
Label1.Text = "You have selected New"
End Sub
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Label1.Text = "You have selected Open"
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
End Class
Jul 11, 2012
14. Drop down list
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With ComboBox1.Items
.Add("CPU")
.Add("RAM")
.Add("Motherboard")
.Add("Hard Disk")
.Add("DVD Drive")
.Add("Monitor")
.Add("Keyboard")
.Add("Mouse")
.Add("Cabinet")
End With
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text &= ComboBox1.SelectedItem & vbCrLf
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label3.Text = "Thank you"
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With ComboBox1.Items
.Add("CPU")
.Add("RAM")
.Add("Motherboard")
.Add("Hard Disk")
.Add("DVD Drive")
.Add("Monitor")
.Add("Keyboard")
.Add("Mouse")
.Add("Cabinet")
End With
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text &= ComboBox1.SelectedItem & vbCrLf
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label3.Text = "Thank you"
End Sub
End Class
Jul 10, 2012
Jul 6, 2012
VB Program - GroupBox
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then
TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Bold)
ElseIf RadioButton2.Checked = True Then
TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Italic)
ElseIf RadioButton3.Checked = True Then
TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Underline)
End If
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then
TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Bold)
ElseIf RadioButton2.Checked = True Then
TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Italic)
ElseIf RadioButton3.Checked = True Then
TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Underline)
End If
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
Jul 5, 2012
VB Program - Ascending order
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label3.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i, j, temp As Integer
Label3.Text = "Numbers in Ascending order"
For i = 0 To ListBox1.Items.Count - 2
For j = i + 1 To ListBox1.Items.Count - 1
If CInt(ListBox1.Items(i)) > CInt(ListBox1.Items(j)) Then
temp = ListBox1.Items(i)
ListBox1.Items(i) = ListBox1.Items(j)
ListBox1.Items(j) = temp
End If
Next j
Next i
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label3.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i, j, temp As Integer
Label3.Text = "Numbers in Ascending order"
For i = 0 To ListBox1.Items.Count - 2
For j = i + 1 To ListBox1.Items.Count - 1
If CInt(ListBox1.Items(i)) > CInt(ListBox1.Items(j)) Then
temp = ListBox1.Items(i)
ListBox1.Items(i) = ListBox1.Items(j)
ListBox1.Items(j) = temp
End If
Next j
Next i
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End
End Sub
End Class
VB Program - Armstrong Number
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num, remin, sum, temp As Integer
num = CInt(TextBox1.Text)
temp = num
sum = 0
While num > 0
remin = num Mod 10
sum = sum + (remin * remin * remin)
num = num \ 10
End While
If temp = sum Then
Label2.Text = "Given number is armstrong"
Else
Label2.Text = "Given number is not armstrong"
End If
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num, remin, sum, temp As Integer
num = CInt(TextBox1.Text)
temp = num
sum = 0
While num > 0
remin = num Mod 10
sum = sum + (remin * remin * remin)
num = num \ 10
End While
If temp = sum Then
Label2.Text = "Given number is armstrong"
Else
Label2.Text = "Given number is not armstrong"
End If
End Sub
End Class
VB Program - Palindrome or not
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim length, i As Integer
Dim v1, v2 As String
length = Len(TextBox1.Text)
For i = 1 To length
v1 = v1 + UCase(Mid(TextBox1.Text, i, 1))
Next i
For i = length To 1 Step -1
v2 = v2 + UCase(Mid(TextBox1.Text, i, 1))
Next i
If v1 = v2 Then
MsgBox("given word is palindrome")
Else : MsgBox("given word is not palindrome ")
End If
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim length, i As Integer
Dim v1, v2 As String
length = Len(TextBox1.Text)
For i = 1 To length
v1 = v1 + UCase(Mid(TextBox1.Text, i, 1))
Next i
For i = length To 1 Step -1
v2 = v2 + UCase(Mid(TextBox1.Text, i, 1))
Next i
If v1 = v2 Then
MsgBox("given word is palindrome")
Else : MsgBox("given word is not palindrome ")
End If
End Sub
End Class
VB program - Generate n Fibonacci numbers
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, y, g, n, i, sum As Integer
n = CInt(TextBox1.Text)
x = 0
y = 1
TextBox2.Text = ""
TextBox2.Text &= CStr(x) & ","
TextBox2.Text &= CStr(y) & " "
For i = 3 To n
sum = x + y
TextBox2.Text &= ", " & CStr(sum)
x = y
y = sum
y = sum
Next i
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, y, g, n, i, sum As Integer
n = CInt(TextBox1.Text)
x = 0
y = 1
TextBox2.Text = ""
TextBox2.Text &= CStr(x) & ","
TextBox2.Text &= CStr(y) & " "
For i = 3 To n
sum = x + y
TextBox2.Text &= ", " & CStr(sum)
x = y
y = sum
y = sum
Next i
End Sub
End Class
VB Programs - Prime or not
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I, N As Integer
N = CInt(TextBox1.Text)
For I = 2 To N - 1
If N Mod I = 0 Then
Label2.Text = "THE NUMBER IS NOT A PRIME NUMBER"
Exit Sub
End If
Next I
Label2.Text = "THE NUMBER IS A PRIME NUMBER"
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I, N As Integer
N = CInt(TextBox1.Text)
For I = 2 To N - 1
If N Mod I = 0 Then
Label2.Text = "THE NUMBER IS NOT A PRIME NUMBER"
Exit Sub
End If
Next I
Label2.Text = "THE NUMBER IS A PRIME NUMBER"
End Sub
End Class
Subscribe to:
Posts (Atom)