Exp-1
|
Addition of Two Numbers |
Coding:
Private Sub Command1_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
Output:
Exp-2 |
Insertion of Picture Box and Image Box |
Coding:
Private Sub Command1_Click()
Picture1.Picture = LoadPicture("E:\VB Class\2. Picture & Image\vijay.jpg ")
End Sub
Private Sub Command2_Click()
Image1.Picture = LoadPicture("E:\VB Class\2. Picture & Image\vijay.jpg ")
End Sub
Output:
Exp-3 |
List Box |
Coding:
Private Sub Form_Load()
List1.AddItem "Lesson1"
List1.AddItem "Lesson2"
List1.AddItem "Lesson3"
List1.AddItem "Lesson4"
End Sub
Output:
Exp-4 |
Combo Box |
Coding:
Private Sub Form_Load ()
Combo1.AddItem "Item1"
Combo1.AddItem "Item2"
Combo1.AddItem "Item3"
Combo1.AddItem "Item4"
End Sub
Output:
Exp-5 |
Check Box |
Coding:
Private Sub Command1_Click()
If Check1.Value = 1 And Check2.Value = 0 Then
MsgBox "Apple is selected"
ElseIf Check2.Value = 1 And Check1.Value = 0 Then
MsgBox "Orange is selected"
ElseIf Check2.Value = 1 And Check1.Value = 1 Then
MsgBox "All are selected"
Else
MsgBox "None of them selected"
End If
End Sub
Output:
Exp-6 |
Option Button |
Coding:
Private Sub Option1_Click()
If Option1.Value = True Then
MsgBox "Male", vbInformation, Gender
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
MsgBox "Female", vbInformation, Gender
End If
End Sub
Output:
Exp-7
|
Dir, Folder, File Extraction
|
Output
Exp-8
|
Label with Image
|
Coding:
Private Sub Command1_Click()
Label1.Caption = “Welcome”
Image1.Visible = True
End Sub
Private Sub Form_Load()
Image1.Visible = False
End Sub
Output:
Exp-9
|
String Concatenation
|
Coding:
Private Sub Command1_Click()
Dim FirstName As String
Dim LastName As String
Dim YourName As String
FirstName = Text1.Text
LastName = Text2.Text
YourName = FirstName + " " + LastName
Label5.Caption = YourName
End Sub
Output:
Exp-10 |
If - Else Statement |
Coding:
Private Sub Command1_Click()
If (LCase(Text1.Text)) = "admin" And (LCase(Text2.Text)) = "admin" Then
Form1.Show
Unload Me
Else
MsgBox "Please Enter Correct Username and Password"
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If (LCase(Text1.Text)) = "admin" And (LCase(Text2.Text)) = "admin" Then
Form1.Show
Unload Me
End If
End Sub
Output:
Exp-11 |
Menu Design |
Coding:
// File Menu
Private Sub new_Click()
RichTextBox1.Text = ""
End Sub
Private Sub open_Click()
RichTextBox1.LoadFile ("E:\VB Class\Menu Design\Document.docx")
End Sub
Private Sub save_Click()
RichTextBox1.SaveFile ("E:\VB Class\Menu Design\Document.docx")
End Sub
Private Sub exit_Click()
Unload Me
End Sub
// Edit Menu
Private Sub copy_Click()
Clipboard.Clear
If RichTextBox1.SelLength > 0 Then Clipboard.SetText RichTextBox1.SelText
End Sub
Private Sub paste_Click()
RichTextBox1.SelText = Clipboard.GetText
ContentChanged = True
End Sub
Private Sub cut_Click()
Clipboard.Clear
If RichTextBox1.SelLength > 0 Then
Clipboard.SetText RichTextBox1.SelText
RichTextBox1.SelText = ""
ContentChanged = True
End If
End Sub
// Format Menu
Private Sub bold_Click()
RichTextBox1.SelBold = True
End Sub
Private Sub italic_Click()
RichTextBox1.SelItalic = True
End Sub
Private Sub underline_Click()
RichTextBox1.SelUnderline = True
End Sub
Private Sub times_Click()
RichTextBox1.SelFontName = "Times New Roman"
End Sub
Private Sub airil_Click()
RichTextBox1.SelFontName = "Arial Black"
End Sub
Private Sub alg_Click()
RichTextBox1.SelFontName = "Algerian"
End Sub
Private Sub size14_Click()
RichTextBox1.SelFontSize = 14
End Sub
Private Sub size18_Click()
RichTextBox1.SelFontSize = 18
End Sub
Private Sub size20_Click()
RichTextBox1.SelFontSize = 20
End Sub
Private Sub bluecolor_Click()
RichTextBox1.SelColor = vbBlue
End Sub
Private Sub greencolor_Click()
RichTextBox1.SelColor = vbGreen
End Sub
Private Sub redcolor_Click()
RichTextBox1.SelColor = vbRed
End Sub
Output:
|
|
|
|
Subscribe by Email
Follow Updates Articles from This Blog via Email
No Comments