Tuesday, February 22, 2011

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