VB
1.Make an application in visual basic, which display a picture when command button with caption "click here "is clicked.
Code:-
Private Sub Command1_Click()
If Picture1.Visible = False Then
Picture1.Visible = True
Else
Picture1.Visible = False
End If
End Sub
2. Design an application to find...
Code:-
Private Sub Command3_Click()
Dim num As Integer
num = Text1.Text
If num Mod 2 = 0 Then
MsgBoxnum& " is even no", vbInformation, "Check for even/odd"
Else
MsgBoxnum& " is odd no", vbInformation, "Check for even/odd"
End If
End Sub
Private Sub Command1_Click()
Dim n, f, i As Integer
f = 1
n = Val(Text1.Text)
For i = 1 To n
f = f * i
Next
MsgBox "Factorial is " & f, vbInformation, "Factorial"
End Sub
Private Sub Command4_Click()
Text1.Text = Clear
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Form()
Text1.SetFocus
End Sub
Private Sub Option1_Click()
Dim i, n, fact, t, x, j, s As Integer
x = Val(Text2.Text) * 3.14 / 180
n = Val(Text4.Text)
For i = 1 To n
s = x
t = (2 * i + 1)
fact = 1
For j = 1 To t
fact = fact * j
Next
s = s + (-1) ^ txt / fact
Text3.Text = s
Next
End Sub
Private Sub Option2_Click()
x = Val(Text2.Text) * 3.14 / 180
n = Val(Text4.Text)
For i = 0 To n
s = x
t = (1 + 1)
fact = 1
For j = 1 To t
fact = fact + j
Next
s = 1 + (-1) ^ (2 + i + 1) + x ^ t / fact
Text3.Text = 1
Next
End Sub
4.Write a VB code to give five choices of colors...
Code:-
Private Sub Option1_Click()
Text1.ForeColor = vbRed
End Sub
Private Sub Option4_Click()
Text1.ForeColor = vbGreen
End Sub
Private Sub Option2_Click()
Text1.ForeColor = vbBlue
End Sub
Private Sub Option5_Click()
Text1.ForeColor = vbYellow
End Sub
Private Sub Option3_Click() Text1.ForeColor = vbMagenta
End Sub
Private sub command1_click()
Unload me
End sub
5.Design an application, which display a text and given choice to change text bold, italic,....
Code:-
Private Sub Checkl_Click()
If Check1.Value = 1 Then
Label1.FontBold = True
Else
Label1. Font Bold = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
Label1. FontItalic = True
Else
Label1. FontItalic = False
End If
End Sub
Private Sub Check3_Click()
If Check3.Value = 1 Then
Label1. Font Underline = True
Else
Label1. Font Underline = False
End If
End Sub
7.Write a program to demonstrate the use of scrollbar slider control.
Code:-
Private Sub HScroll1_Change ()
Me.BackColor=RGB (HScroll1.Value,HScroll2.Value,HScroll3.Value)
End sub
Private Sub HScroll2_Change ()
Me.BackColor=RGB (HScroll1.Value,HScroll2.Value,HScroll3.Value)
End sub
Private Sub HScroll3_Change ()
Me.BackColor=RGB (HScroll1.Value,HScroll2.Value,HScroll3.Value)
End sub
8. Write a program to add item from a text box to combo box and from combo box to list box ..
Code:-
Private Sub Combo1_Click() Listl.AddItem Combo1.List(Combo1.listindex)
End sub
Private Sub Command1_Click()
Combol.AddItem (Text1.Text)
MsgBox "Item Added Successfully", vbInformation, "Adding Item" End Sub.ListIndex)
End Sub
Private Sub Command2_Click()
If List1.ListIndex >= 0 Then
List1.RemoveItem (List1.ListIndex)
MsgBox "Item Deleted Successfully", vbInformation, "Deleting Items"
Else
MsgBox "Select an item first",vbCritical
End If
End Sub
Private sub command 3_click()
Unload me
End sub
15. Create a data project using ADO Data control,Write code for the following methods. Move First, movelast, moveprevias and move Next use customer table of NWIND database.
Private sub command1_click()
Adodcl.recordset.move first
End sub
Private sub command2_click()
If not adodcl.recordset. BOF then Adodcl.recordset.move.previous
End If
Private sub command3_click() Adodcl.recordset.movelast
End sub
Private sub command4_click()
If Not Adodcl.recordset.Eof then
Adodcl.recordset.movenext
End sub