0% found this document useful (0 votes)
5 views

Source Code - VB

This document provides code examples for several basic Visual Basic projects including displaying message boxes, password validation, string concatenation, number multiplication, checking leap years, calculating addition and averages, and copying text between text boxes. The code examples demonstrate fundamentals of Visual Basic programming.

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Source Code - VB

This document provides code examples for several basic Visual Basic projects including displaying message boxes, password validation, string concatenation, number multiplication, checking leap years, calculating addition and averages, and copying text between text boxes. The code examples demonstrate fundamentals of Visual Basic programming.

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Visual Basic Project

 Display Message Box by Pressing Command Button:-


Source Code : Output :

Private Sub CommandButton1_Click()

MsgBox ("Welcome to Visual Basic")

End Sub

 Password Programs:-
Source Code : Output :

Private Sub CommandButton1_Click()

If TextBox1.Text = (192) Then

MsgBox ("Password Accepted")

Else

MsgBox ("Wrong Password")

End If

End Sub
 Joining Two String (Concatenation) :-
Source Code : Output :

Private Sub CommandButton1_Click()

TextBox3.Text = TextBox1.Text + " " + TextBox2.Text

End Sub

 Multiplication of Number :-
Source Code : Output :

Private Sub CommandButton1_Click()

TextBox3.Text = Val(TextBox1.Text) *
Val(TextBox2.Text)

End Sub

Private Sub CommandButton2_Click()

TextBox1.Text = ""

TextBox2.Text = ""

TextBox3.Text = ""

End Sub
 Checking Leap Year :-

Source Code : Output :

Private Sub CommandButton1_Click()


Dim a As Integer
a = Val(TextBox1.Text)
If a Mod 4 = 0 Then
TextBox2.Text = "This is Leap Year"
Else
TextBox2.Text = "This is not Leap Year"
End If
End Sub
Private Sub CommandButton2_Click()
TextBox1.Text = ""
TextBox2.Text = ""
End Sub

 Calculate Addition and Average:-


Source Code : Output :

Private Sub CommandButton1_Click()

TextBox4.Text = Val(TextBox1.Text) +
Val(TextBox2.Text) + Val(TextBox3.Text)

TextBox5.Text = Val(TextBox1.Text) +
Val(TextBox2.Text) + Val(TextBox3.Text) / 3

End Sub

Private Sub CommandButton2_Click()

Unload Me

End Sub
 Copy Text from one Text Box to Another Text Box :-

Source Code : Output :

Private Sub CommandButton1_Click()

TextBox2.Text = TextBox1.Text

End Sub

Private Sub CommandButton2_Click()

TextBox1.Text = ""

TextBox2.Text = ""

End Sub

Private Sub CommandButton3_Click()

Unload Me

End Sub

You might also like