Sunday, January 13, 2013

Mini Project VB


Visual Basic is a third-generation event-driven programming language and integrated development environment  from Microsoft for its COM programming model first released in 1991. Visual Basic is designed to be relatively easy to learn and use. Visual Basic was derived from BASIC and enables the rapid application development of graphical user interface  applications, access to databases using Data Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects. VBA is effectively the same language as Visual Basic but VBA-code is tied to Microsoft Office and can only run within that environment. The scripting language VBScript is a subset of Visual Basic.
A programmer can put together an application using the components provided with Visual Basic itself. Programs written in Visual Basic can also use the Windows API, but doing so requires external function declarations. Though the program has received criticism for its perceived faults, from version 3 Visual Basic was a runaway commercial success, and many companies offered third party controls greatly extending its functionality.




Visual Basic was designed to be easily learned and used by beginner programmers. The language not only allows programmers to create simple GUI applications, but to also develop complex applications. Programming in VB is a combination of visually arranging components or controls on a form, specifying attributes and actions of those components, and writing additional lines of code for more functionality. Since default attributes and actions are defined for the components, a simple program can be created without the programmer having to write many lines of code. Performance problems were experienced by earlier versions, but with faster computers and native code compilation this has become less of an issue.
Although VB programs can be compiled into native code executables from version 5 onwards, they still require the presence of runtime libraries of approximately 1 MB in size. Runtime libraries are included by default in Windows 2000 and later, however for earlier versions of Windows.




Examples:

     Private Sub Command 1_Click()
      Text1.Text = "Sathya"
      Text2.Text = "24"
      End Sub
    Private Sub Form_Load()
    Me.WindowState = 2
     End Sub
output :









Program 2:
Dim a, b As Integer
Private Sub Command 1_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a + b
End Sub
Private Sub Command 2_Click()
a = Val(Text1. Text)
b = Val(Text2. Text)
Text3.Text = a - b
End Sub
Private Sub Command 3_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a * b
End Sub
Private Sub Command 4_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a / b
End Sub
Private Sub Command 5_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Command 6_Click()
Unload Me
End Sub
Output:












Program 5:
 In coding window change       Tools        Add Procedure        Name Swap        Click Function
Private Sub Command1_Click()
SWAP Text1.Text, Text2.Text
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub             
Public Function SWAP(ByRef a As Integer, ByRef b As Integer)
Text1.Text = b
Text2.Text = a
End Function
Private Sub Command3_Click()
End
End Sub
Output: Before Swapping:
After Swapping:
Program 6:
Dim p, q As Integer
Private Sub Command1_Click()
p = Text3.Text
q = Text4.Text
Text5.Text = p * q
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.WindowState = 2
End Sub
Output:
Program 7:
Dim p, n, r As Integer
Private Sub Command1_Click()
p = Text1.Text
n = Text2.Text
r = Text3.Text
Text4.Text = p * n * r / 100
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.WindowState = 2
End Sub
Output:
Program 8:
Private Sub Command1_Click()
Text3.Text = Text1.Text + Text2.Text
End Sub
Private Sub Command2_Click()
Text3.Text = Len(Text1.Text + Text2.Text)
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Me.WindowState = 2
End Sub
Private Sub Option1_Click()
Text3.Text = UCase(Text3.Text)
End Sub
Private Sub Option2_Click()
Text3.Text = LCase(Text3.Text)
End Sub
Output:


Program 9:
Dim mark As Integer
Dim msg As String
Private Sub cmdclr_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End Sub
Private Sub cmdexit_Click()
End
End Sub
Private Sub cmdresult_Click()
mark = Text3.Text
If mark >= 75 And mark <= 100 Then
msg = Text1.Text + "  has obtained Distinction in  " + Text2.Text + "."
Text4.Text = msg
ElseIf mark >= 65 And mark <= 74 Then
msg = Text1.Text + "has obtained first class in" + Text2.Text + "."
Text4.Text = msg
ElseIf mark >= 50 And mark < 64 Then
msg = Text1.Text + "has obtained second class in" + Text2.Text = "."
Text4.Text = msg
ElseIf mark > 35 And mark <= 49 Then
msg = Text1.Text + "has obtained pass mark in" + Text2.Text + "."
Text4.Text = msg
Else
Text4.Text = msg
msg = Text1.Text + "has failed in" + Text2.Text + "."
End If
End Sub
Output:











Program 10:
Private Sub Command1_Click()
If optagra.Value = True Then
MsgBox "Your Answer is Correct"
Else
MsgBox "Your is Wrong"
End If
End Sub
Private Sub Form_Load()
optagra.Value = False
optmumbai.Value = False
optnepal.Value = True
End Sub            
Output:

Program 11:
Private Sub Command1_Click()
If Option1.Value = True Then
msg = "Hello Mr." + Text1.Text + "Welcome to Techcorner Computer Education centre"
Text2.Text = msg
ElseIf Option2.Value = True Then
msg = "Hello Miss . " + Text1.Text + "Welcome to Tech Corner Computer Education centre"
Text2.Text = msg
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Output:

Program 12:
Private Sub Check1_Click()
If Check1.Value = vbChecked Then
Text1.FontBold = True
Text1.FontItalic = True
Else
Text1.FontBold = False
Text1.FontItalic = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = vbChecked Then
Text1.FontBold = True
Else
Text1.FontBold = False
End If
End Sub
Private Sub Check3_Click()
If Check3.Value = vbChecked Then
Text1.FontItalic = True
Else
Text1.FontItalic = False
End If
End Sub
Private Sub Check4_Click()
If Check4.Value = vbChecked Then
Text1.FontUnderline = True
Else
Text1.FontUnderline = False
End If
End Sub
Private Sub Command1_Click()
Text1.Text = ""
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Me.WindowState = 2
End Sub
Private Sub Option1_Click()
Text1.ForeColor = vbRed
End Sub
Private Sub Option2_Click()
Text1.ForeColor = vbBlue
End Sub
Private Sub Option3_Click()
Text1.ForeColor = vbGreen
End Sub
Private Sub Option4_Click()
Text1.ForeColor = vbBlack
End Sub
Private Sub Option5_Click()
Text1.FontSize = 10
End Sub
Private Sub Option6_Click()
Text1.FontSize = 15
End Sub
Private Sub Option7_Click()
Text1.FontSize = 20
End Sub
Private Sub Option8_Click()
Text1.FontSize = 24
End Sub
Output:

 Program 13:
Private Sub Command1_Click()
MsgBox "Your Travel Starts From " + Combo1.Text + " End with " + Combo2.Text
End Sub
Private Sub Command2_Click()
End
End Sub
Output:







No comments:

Post a Comment