Sunday, January 26, 2020
Microsoft Visual Basic Programming Language Computer Science Essay
Microsoft Visual Basic Programming Language Computer Science Essay Microsoft Visual Basic is a programming language is which is easier and simpler to use than other programming languages for example Java, Programming in C, programming in C++. Visual basic is an ideal language for developing Windows-based, Database and Internet applications. Windows-based applications are event driven and they need good graphical user interface (GUI) support. Internet applications require web page programming support. Visual Basic provides a scripting language called VBScript to help you control and make your web pages interactive. Visual Basic can also be used to access database created using database management software (DBMS) such as Access 2000, SQL Server 7.5 and FoxPro. Visual Basic also supports both traditional procedure-oriented programming and the newer object-oriented programming (OOP). Visual Basic is one of the members of a group of software called Visual Studio. The other members of this group are Visual Studio Tools, Visual C++, Visual J++, Visual FoxPro and Visual InterDev. There are four versions of Visual Basicà ¢Ã ¢Ã¢â¬Å¡Ã ¬Working Model, Learning Edition, Professional Edition and Enterprise Edition. The Visual Basic environment is where users can create and test their projects. The Visual Basic environment consists of several windows such as: The Title bar- displays the projects name(Project1). The default project name is Project1. Subsequent projects are named Project2, Project3, etc. Besides the project name, the title bar also contains several icons. The buttons on to the right are the standard windows buttons that can use to minimize, restore or close the window. Menu Bar- has the usual menu items such as File, Edit, View, Project, Run and Tools. Tool Bar- contains several icons, each of which represents a command. These icons provide a shortcut to the most frequently used commands. Toolbox- Located at the left hand side of the of the main window, contains a set of icons, each of which represent control object or just control. Form window- The window at the center of the main screen is the Form window. This is where the user can design their application. When the user begins a project, Visual Basic gives a new form with the default form named Form1. These are the few items and tool featured in a Visual Basic environment. Question 1 Write a program to produce the following output: Main Menu For Loop While Loop Select your Choice: 1 Using For Loop to Display the pattern 1 22 333 Do you want to continue(Y/N)? Y Main Menu For Loop While Loop Select your Choice: 2 Using while Loop to Display the pattern 1 22 333 Do you want to continue(Y/N)? N Press any key to continue Output For Question 1 Module Module1 Sub Main() Dim i, j As Int32 Do Dim a As Integer Console.WriteLine(Main Menu) Console.WriteLine(1-For Loop) Console.WriteLine(2-While Loop) Console.WriteLine(Select Your Choice) a = Console.ReadLine() If a = 1 Then Dim k As Int32 = 1 Console.WriteLine(Using For Loop to Display the pattern) For i = 1 To 3 Console.WriteLine() For j = 1 To i Console.Write(k.ToString) Next j k += 1 Next i Dim b As Char Console.WriteLine(vbCrLf) Console.WriteLine(Do You Want To Continue (Y/N)?) b = Console.ReadLine() If (b = Y) Then Else End End If ElseIf (a = 2) Then Console.WriteLine(Using While Loop to Display the pattern) Console.WriteLine(vbCrLf) Dim counter As Integer = 1 While counter Console.WriteLine(StrDup(counter, CChar(counter.ToString))) counter += 1 End While Dim b As Char Console.WriteLine(vbCrLf) Console.WriteLine(Do You Want To Continue (Y/N)?) b = Console.ReadLine() If (b = N) Then End End If Else Console.WriteLine(Please key 1/2) End If Loop End Sub End Module Source Code For Question For the first question was done using if else statements to determine wheter to print out for loop or while loop by assigning conditions, for example a=1 for for loop and a=2 for while loop. The variable a is set with Dim As Integer meaning as assigned with 1 and 2. The for and while loop codes are above whitin the codition. For the Looping of the statement was done by using Do loop, that the Menu can loop again. Using Console.WriteLine to print the output and using Console.ReadLine for input, Console.WriteLine(vbCrLf) for new line. Dim Char is to represent a single character in this case either using Y or N option to continue with the program. Dim Integer to represent number without decimal place. Question 2 The numbers of calories burned per hour cycling, jogging, and swimming are 200, 475, and 275, respectively. A person loses 1 pound of weight for each 3500 calories burned. Write a program that allows the user to input the number of hours spent at each activity and then calculates the number of pounds worked off. The Output For Question 2 The following image above is my output for question 2. This was done using Microsoft Visual.NET 2003. Briefly explaining the element used to create this was Label, text, Radiobuttons and a button. So this was to test the number of hours that the user has done using the following 3 choices above. So after the selection of one of the radiobuttons the output will be displayed in pounds, as where the number of pounds shed by the user. The following interaction was done by the button. The codes are set in the button so when the user click the result is displayed. For more detailed explanation of the code is below. The codes for the button for Question 2 Using Dim as Double enables the user to have decimal places compared to integer/ Using 3 variables a, b, and c respectively to represent each of following hours cycling, jogging and swimming. Using the if statements to achieve the result for the corresponding activities for each. The raddiobuttons are the following activities that represents cycling, jogging and swimming. The value of each is multiplied by the value given by the question as 200,475 and 275 and then each of them are divide by the number of calories which is 3500. Conclusion A Visual Basic application or project typically requires some input, processing and output. For interaction with the user the project will typically use several controls such as forms, text and picture boxes, labels and command buttons. Using these control, the user can control the program execution. Planning a Visual Basic project basically involves the following steps: Plan the project. This involves determining what to do. Designing the User Interface. The interface is the most visible part of the project. It is used to interact with the system. The user can determine the controls ( e.g., command buttons, text boxes, labels) that are needed to enter data (input), to display results of computation (output), and to control the program execution (processing). Set the properties of the controls. Determine the controls that the user will need or their project and set the properties (e.g., appearance, name, caption, color) for each of the controls used. Write the code (program). The code represents the action that must take when the user clicks on a Command button. Clicking a Command button is called an event and the code represents a response to that event Test and debug the code. This is done to ensure that the program works correctly These steps help the user to analyze first, plan using draft and then apply his information gathered into motion. These steps are a require that every programmer must do in order to achieve full satisfaction of their program.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.