1 / 21

In The Name Of Allah

Lab 01 Forms in excel. In The Name Of Allah. 1. Insert form into your project. 2. Change form’s properties. 3. Put controls on the form. 4. Change controls’ properties. 5. Write code. 6. Use Show method to display the form. objectives. VBA : • Standard programming language for office

Download Presentation

In The Name Of Allah

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 01 Forms in excel TahaniALdweesh In The Name Of Allah

  2. 1. Insert form into your project. 2. Change form’s properties. 3. Put controls on the form. 4. Change controls’ properties. 5. Write code. 6. Use Show method to display the form. Tahani ALdweesh objectives

  3. VBA : • Standard programming language for office programs . • Can be used in any office applications in same way . • As you do more work with VBA you will need to use VBE(Visual Basic Editor ), TahaniALdweesh VBA Visual Basic For Application

  4. :The Visual Basic Editor (VBE) is the environment in which you work with VBA programming code. TahaniALdweesh Visual Basic Editor

  5. TahaniALdweesh -Open Microsoft Excel - Tools > Macro > Visual Basic Editor (2003) ALT + F11 .user form < -insert

  6. TahaniALdweesh • The Visual Basic Editor windows Project window User Form Work Area properties window

  7. Project window: shows a hierarchical view of the contents of the current VBA project view  project explorer or Ctrl+R Properties window: shows the various properties available for whatever object that is highlighted view  Properties window or F4 User form window : the design area ,the toolbox will appear by default insert user form Code window: where the procedures take place view code or F7 Work area: the rest of the VBE TahaniALdweesh

  8. Properties are the physical descriptions of all Excel objects, and the description of the particular property is called the value of the property. Contains detailed information about any selected part of a project in .the Project Explorer TahaniALdweesh Properties Window

  9. TahaniALdweesh ToolBoxs ToolBox

  10. • Label: used to instruct the user • Textbox: enables the user to enter textual info. • List box: list of choices. • Checkbox: allow you to choose more than one option. • Combo box: is so named because it combines the function of textbox and a list box. • Option buttons: restricts the user to one choice. • Frame: used for: 1-groups option buttons 2-visually, arranging different portions of the form TahaniALdweesh

  11. In term of VB, variablesare areas allocated by the computer memory to hold data. Like the mail boxes, each variablemust be given a name.To name a variable in Visual Basic, you have to follow a set of rules. Tahani ALdweesh Vb code

  12. variablesThe following are the rules when naming the :in Visual Basic • It must be less than 255 characters. • Must start with a letter (a to z, A to Z). • It must not begin with a number. • No spacing is allowed . • Can contain any number of letters or digits (a digit is 0 to 9). • Can contain the underscore. TahaniALdweesh Variable Names

  13. TahaniALdweesh Examples of valid and invalid variablenames

  14. Declaring Variables In Visual Basic, one needs to declare the variables before using them by assigning names and data types. They are normally declared in the general section of the codes' windows using the Dim statement. The format is as follows: DimVariable Name As Data Type TahaniALdweesh Vb code

  15. Dim password As String Dim yourName As String Dim firstnum As Integer Dim secondnum As Integer Dim total As Integer Dim doDate As Date • You may also combine them in one line , separating each variable with a comma, as follows: Dim password As String , yourName As String, firstnum As Integer TahaniALdweesh Example

  16. Constants are different from variables in the sense that their values do not change during the running of the program. Declaring a Constant ConstConstant Name As Data Type = Value :• Example Const Pi As Single=3.142 Const Temp As Single=37 Const Score As Single=100 TahaniALdweesh Constraints

  17. After declaring various variables using the Dim statements, we can assign :values to those variables. The general format of an assignment is Variable=Expression • The variable can be a declared variable or a control property value. • The expression could be a mathematical expression, a number, a string, a Boolean value (true or false) and more. TahaniALdweesh Assigning Values to Variables

  18. firstNumber=100 secondNumber=firstNumber-99 userName="John Lyan" userpass.Text = password Label1.Visible = True Command1.Visible = false Label4.Caption = textbox1.Text ThirdNumber = Val(usernum1.Text) total = firstNumber+secondNumber+ThirdNumber TahaniALdweesh Examples:

  19. TahaniALdweesh Circle aRea Program :

  20. Private Sub CommandButton1_Click() Dim rad As Double rad = Val(TextBox1.Text) Dim area As Double area = 3.17 * rad * rad TextBox2.Text = area End Sub Private Sub CommandButton2_Click() UserForm1.Hide End Sub TahaniALdweesh The Code is :

  21. TahaniALdweesh Any Question

More Related