Tuesday, February 22, 2011

Visual Basic Programs Lists With output

LIST of visual basic (VB) Programs with output.


1. WAP procedure to convert name in abbreviation.

2. WAP in VB to calculator.

3. WAP to make use of AND and OR operator.

4. WAP to arrange each row in descending order throw grid control.

5. WAP to check given number is palindrome or not by using form.

6. WAP for developing paint brush in VB.

7. WAP for displaying all Prime numbers.

8. WAP in which integer number is entered by the user and its table is printed on form.

9. WAP to add text in a list and remove it from the list and to clear the list.

10. WAP in which by moving the horizontal scroll bar the color of the font ranges and each of three horizontal scroll bar represent red, blue, green colors by using RGB built in function.

11. WAP to print the factorial of any number.

12. WAP for generating Fibonacci series.

13. WAP for making a combo box which contains the country names and shows the capital for corresponding country in another combo box.

14. WAP to check whether the given number is even or odd.

15. WAP to find the greatest number among three numbers.

16. WAP to find the simple interest.

17. WAP to show your personal profile on the form.

18. WAP to find the length of entered text.

19. WAP to find the sum, average, division using command buttons.

20. WAP in VB to read the string first and find the reverse string and delete all the vowels.



Write a Visual Basic program to read the string first and find the reverse string and delete all the vowels

WAP in VB to read the string first and find the reverse string and delete all the vowels.
_____________________________________________________________

Dim a
Private Sub Command1_Click()
a = StrReverse(Text1.Text)
Label2.Caption = a
End Sub

Private Sub Command2_Click()
a = Replace(a, "a", "")
a = Replace(a, "A", "")
a = Replace(a, "e", "")
a = Replace(a, "E", "")
a = Replace(a, "i", "")
a = Replace(a, "I", "")
a = Replace(a, "o", "")
a = Replace(a, "O", "")
a = Replace(a, "u", "")
a = Replace(a, "U", "")
Label3.Caption = a
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub

_______________________________________________________
OUTPUT
_______________________________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic program to find Sum, Average, Division, using command buttons

WAP to find Sum, Average, Division, using command buttons.
____________________________________________

Dim a, b, c, d, e
Private Sub Command1_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a + b
Label3.Caption = c
End Sub

Private Sub Command2_Click()
d = c / 2
Label3.Caption = d
End Sub

Private Sub Command3_Click()
e = a / b
Label3.Caption = e
End Sub

Private Sub Command4_Click()
End
End Sub

Private Sub Form_Load()

End Sub

___________________________________
OUTPUT
___________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic program to find length of entered text

WAP to find length of entered text.
________________________________

Private Sub Command1_Click()
Dim a, b
a = Text1.Text
b = Len(a)
Label2.Caption = b
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Label2.Caption = "OUTPUT"

End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub

___________________________________
OUTPUT
___________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic program to show your personal profile on the form

WAP to show your personal profile on the form.
_______________________________________

Dim a, b, c, d, e, f, g
Private Sub Command1_Click()
a = InputBox("Enter Your Name:")
b = InputBox("Enter Your Fathers Name:")
c = InputBox("Enter Your Department Name:")
d = InputBox("Enter Your Roll No. :")
e = InputBox("Enter Your Session:")
f = InputBox("Enter Your Address:")
g = InputBox("Enter Your Phone No. :")
End Sub

Private Sub Command2_Click()
Text1.Text = a
Text2.Text = b
Text3.Text = c
Text4.Text = d
Text5.Text = e
Text6.Text = f
Text7.Text = g
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub
__________________________________
OUTPUT
__________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic program to Find the simple interest

WAP to Find the simple interest.
_______________________________
Private Sub Command1_Click()
Dim a
Dim b, c, d As Double

a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = (a * b * c) / 100
Label6.Caption = d




End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label6.Caption = ""

End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub

______________________________
OUTPUT
______________________________




____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program to find the greatest among three numbers

WAP to find the greatest among three numbers.
_________________________________________

Private Sub Command1_Click()
Dim a
a = Val(Text1.Text)

If Text1.Text = "" Then
Label2.Caption = "ENTER ANY INTERGER"
ElseIf a Mod 2 = 0 Then
Label2.Caption = "Even Number"
Else
Label2.Caption = "Odd Number"
End If
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Label2.Caption = ""
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub

_______________________________________
OUTPUT
_______________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program to check whether the given number is even or odd

WAP to check whether the given number is even or odd.
_____________________________________________

Private Sub Command1_Click()
Dim a
a = Val(Text1.Text)

If Text1.Text = "" Then
Label2.Caption = "ENTER ANY INTERGER"
ElseIf a Mod 2 = 0 Then
Label2.Caption = "Even Number"
Else
Label2.Caption = "Odd Number"
End If
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Label2.Caption = ""
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub

________________________________________
OUTPUT
________________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form
Download its Image



Write a Visual Basic program for making a combo box which contains the country names and shows the capital for corresoponding country in another comb

WAP for making a combo box which contains the country names and shows the capital for corresoponding country in another combo box.
_______________________________________________________________



Private Sub Command1_Click()
If Combo1.ListIndex = 0 Then
Combo2.Clear
Combo2.AddItem ("NEW DELHI")
ElseIf Combo1.ListIndex = 1 Then
Combo2.Clear
Combo2.AddItem ("ISLAMABAD")
ElseIf Combo1.ListIndex = 2 Then
Combo2.Clear
Combo2.AddItem ("COLOMOW")
ElseIf Combo1.ListIndex = 3 Then
Combo2.Clear
Combo2.AddItem ("KATHMANDU")
ElseIf Combo1.ListIndex = 4 Then
Combo2.Clear
Combo2.AddItem ("TOKYO")
Else
MsgBox ("Select Valid Country")
End If
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Form_Load()
Combo1.AddItem ("INDIA")
Combo1.AddItem ("PAKISTAN")
Combo1.AddItem ("SRILANKA")
Combo1.AddItem ("NEPAL")
Combo1.AddItem ("JAPAN")
End Sub

_________________________________________________
OUTPUT
_________________________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic programs for generating Fibonacci series.

WAP for generating Fibonacci series.
___________________________________

Private Sub Command1_Click()
List1.Clear
num = Val(Text1.Text)
a = 0
b = 1
c = 0
List1.AddItem (a)
List1.AddItem (b)
For i = 1 To num Step 1
c = a + b
List1.AddItem (c)
a = b
b = c
Next i
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Form_Load()
List1.Clear

End Sub
________________________________
OUTPUT
________________________________



DOWNLOAD

____________________________________

Download its form

Download its Image



Write a Visual Basic program to print the factorial of any number

WAP to print the factorial of any number.
___________________________________

Private Sub Command1_Click()
a = Val(Text1.Text)
Call fact(a)
End Sub

Private Sub Command2_Click()
End
End Sub
Public Function fact(a)
If a = 0 Then
fact = 1
Text2.Text = fact
Else
fact = a * fact(a - 1)
Text2.Text = fact
End If
End Function

Private Sub Form_Load()

End Sub

_____________________________________
OUTPUT
_____________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program in which by moving the horizontal scroll bar the color of the font ranges and each of three horizontal scroll bar represe

WAP in which by moving the horizontal scroll bar the color of the font ranges and each of three horizontal scroll bar represents red, blue, green colors by using RGB built in function.
____________________________________________________________________
Private Sub Command1_Click()
'Text1.BackColor = 255
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
Text1.Enabled = False
HScroll1.Max = 255
HScroll1.Min = 0
HScroll1.SmallChange = 1
HScroll1.LargeChange = 2
HScroll1.Value = 255
HScroll2.Max = 255
HScroll2.Min = 0
HScroll2.SmallChange = 1
HScroll2.LargeChange = 2
HScroll2.Value = 0
HScroll3.Max = 255
HScroll3.Min = 0
HScroll3.Value = 0
HScroll3.SmallChange = 1
HScroll3.LargeChange = 2
End Sub

Private Sub HScroll1_Change()
Text1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub

Private Sub HScroll2_Change()
Text1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub

Private Sub HScroll3_Change()
Text1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub

__________________________________________________________
OUTPUT
__________________________________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program to add text in a list and remove it from the list and to clear the list

WAP to add text in a list and remove it from the list and to clear the list.
___________________________________________________________

Private Sub Command1_Click()
a = InputBox("ENTER Item in the List BOX")
List1.AddItem (a)
End Sub

Private Sub Command2_Click()
List1.Clear
End Sub

Private Sub Command3_Click()
List1.RemoveItem (List1.ListIndex)
End Sub

Private Sub Command4_Click()
End
End Sub

Private Sub Form_Load()

End Sub

___________________________________________
OUTPUT
___________________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic program in which integer number is entered by the user and its table is printed on form

WAP in which integer number is entered by the user and its table is printed on form.
___________________________________________________________
Private Sub Command1_Click()
Dim a, i, j, k
a = Val(Text1.Text)
If a > 0 Then
For i = 0 To 9
For j = a To a
k = Str(j) & " * " & Str(i) & " = " & i * j
Print k
Next j
Next i
Else
MsgBox ("Number is less then or equal to zero")
End If
End Sub

Private Sub Command2_Click()
Text1.Text = ""
table.Cls
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub
___________________________________________________
OUTPUT
___________________________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program for displaying all prime numbers below 10000

WAP for displaying all prime numbers .
______________________________________

Dim a

Private Sub clear_cmd_Click()
List1.Clear

End Sub

Private Sub exit_cmd_Click()
End
End Sub

Private Sub Form_Load()

End Sub

Private Sub generate_cmd_Click()
List1.Clear
a = Val(Text1.Text)
For i = 2 To a Step 1
For j = 2 To i Step 1
If i Mod j = 0 Then
GoTo S
ElseIf j + 1 = i Then
a = i
List1.AddItem (a)
End If
Next j
S:
Next i




End Sub


_______________________________________
OUTPUT
_______________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program to developing paint brush

WAP for developing paint brush in VB.
_______________________________

Private Sub Command1_Click()
Unload Me

End Sub

Private Sub Form_Load()
With Combo1
.AddItem 1
.AddItem 2
.AddItem 4
.AddItem 8
.AddItem 16
.AddItem 32
.AddItem 64
End With
Combo1.ListIndex = 0
With Combo2
.AddItem "Black"
.AddItem "Red"
.AddItem "Green"
.AddItem "Blue"
.AddItem "White"
End With
Combo2.ListIndex = 0

End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
Picture1.CurrentX = x
Picture1.CurrentY = Y

End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Dim colour As String
If Button = 1 Then
Picture1.DrawWidth = Combo1.text
If Combo2.text = "Black" Then colour = vbBlack
If Combo2.text = "Red" Then colour = vbRed
If Combo2.text = "Green" Then colour = vbGreen
If Combo2.text = "Blue" Then colour = vbBlue
If Combo2.text = "White" Then colour = vbWhite
Picture1.Line (Picture1.CurrentX, Picture1.CurrentY)-(x, Y), colour
End If

End Sub

____________________________________
OUTPUT
____________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program to check given no. is Palindrome or not by using Form

WAP to check given no. is Palindrome or not by using Form.
_________________________________________________

Private Sub Command1_Click()
Dim a, b, c
a = Text1.Text
b = StrReverse(Text1.Text)
c = StrComp(a, b)
If (c = 0) Then
Text2.Text = "Given string is Palindrome!"
Else
Text2.Text = "Given Sting is not a Palindrome!"
End If
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""

End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub


_____________________________________________
OUTPUT
_____________________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program to arrange each row in descending order throw grid control

WAP to arrange each row in descending order throw grid control.

______________________________________________________

Dim i
Private Sub Command1_Click()
MSFlexGrid1.Col = 0 'Set primary key for sorting row
MSFlexGrid1.Sort = 1 'sort in descending order
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Form_Load()
MSFlexGrid1.Rows = 4
MSFlexGrid1.Cols = 4
For i = 0 To 3
MSFlexGrid1.RowHeight(i) = 500
MSFlexGrid1.ColWidth(i) = 2200
Next
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "ROLL NUMBER"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "NAME"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "ADDRESS"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "PHONE NUMBER"

MSFlexGrid1.Row = 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "1"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "Sanjay"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "Palam, New Delhi"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "9910358270"

MSFlexGrid1.Row = 3
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "2"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "Soni"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "Palam, Delhi"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "011-25253480"

MSFlexGrid1.Row = 2
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "3"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "Krishna"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "Delhi"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "011-58025910"
End Sub

___________________________________________________
OUTPUT
___________________________________________________

First Image



Second Image



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image 1

Download its Image 2



Write a Visual Basic Programs to use of AND and OR operator

WAP to make use of AND and OR operator
______________________________________


Dim a As Boolean
Private Sub Command1_Click()
Dim c, d
c = Val(Text1.Text)
d = Val(Text2.Text)
a = c > 0 And d > 0
Label3.Caption = a

End Sub

Private Sub Command2_Click()
Dim c, d
c = Val(Text1.Text)
d = Val(Text2.Text)
a = c > 0 Or d > 0
Label3.Caption = a
End Sub

Private Sub Form_Load()

End Sub

__________________________________
OUTPUT
__________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a visual Basic Calculator Programs

WAP in VB to Calculator.
___________________________________
Dim num1 As Double
Dim num2 As Double
Dim sum As Double
Dim choice As String
Private Sub cmd_Click(Index As Integer)
Label1.Caption = Label1.Caption & cmd(Index).Caption
num1 = Val(Label1.Caption)
End Sub

Private Sub Command1_Click()
num1 = -num1
Label1.Caption = Str(num1)
End Sub

Private Sub Command13_Click()
num2 = num1 = 0
Label1.Caption = ""
End Sub

Private Sub Command14_Click()
Label1.Caption = ""
num2 = num1
num1 = 0
choice = "-"
End Sub

Private Sub Command15_Click()
Label1.Caption = ""
num2 = num1
num1 = 0
choice = "*"
End Sub

Private Sub Command16_Click()
Label1.Caption = ""
num2 = num1
num1 = 0
choice = "/"
End Sub

Private Sub Command17_Click()
Select Case choice
Case "+"
sum = num2 + num1
Label1.Caption = Str(sum)
Case "-"
sum = num2 - num1
Label1.Caption = Str(sum)
Case "*"
sum = num2 * num1
Label1.Caption = Str(sum)
Case "/"
sum = num2 / num1
Label1.Caption = Str(sum)
End Select
End Sub

Private Sub Command18_Click()
End
End Sub

Private Sub Command4_Click()
Label1.Caption = ""
num2 = num1
num1 = 0
choice = "+"
End Sub

Private Sub Form_Load()

End Sub
__________________________________
OUTPUT
__________________________________





____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



Write a Visual Basic Program (VB) to convert name in abbreviation

WAP Procedure to convert name in abbreviation
___________________________________________
Private Sub Command1_Click()
Call convert
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""

End Sub

Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text2.Enabled = False
Text2.FontSize = 22

End Sub
Public Sub convert()
Dim a, b, c, d, i, j, k, l, m
l = Len(Text1.Text)
If Text1.Text <> "" Then
a = Mid(Text1.Text, 1, 1)
b = InStr(1, Text1.Text, " ")
If b <> 0 Then
Text2.Text = "YeS"
c = Mid(Text1.Text, b + 1, 1)
i = InStr(b + 1, Text1.Text, " ")
If i <> 0 Then
j = Mid(Text1.Text, i + 1, 1)
d = UCase(a + "." + c + "." + j)
m = InStr(i + 1, Text1.Text, " ")
If m <> 0 Then
Text1.Text = "Only Three strings allowed"
d = "RE Enter"

End If

Else
j = Mid(Text1.Text, b + 1, 1)
d = UCase(a + "." + j)

End If


Else
k = Mid(Text1.Text, 1, 3)
d = UCase(k + ".")
End If


Else
d = "ENTER TEXT"
End If

Text2.Text = d
End Sub
____________________________________

OutPut
____________________________________



____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image