Lecture2 Introduction To Visual Basic Prepared by Ahmed
Lecture-2 Introduction To Visual Basic Prepared by: Ahmed Sabeeh Yousif Master in Computer Engineering &Microelectronics System Lecturer In: Northern Technical University College of Technical Administrative/Mousl Department of E- Management Techniques Second year –Undergraduate 2018 -2019 Visual Basic
Outline • Project window. • Form layout window. • Explain Main window(menus(menu bar)) theoretical and practical. • Explain Properties window: ü Names, size and location , fonts &color ü Tab , mouse pointer properties.
Project window
Form layout • It can use for: • Identify the screen position when run the program. • Identify the screen resolution by (clicking on the mouse -right click on the square and choose(resolution guide)
Menu bar
Menu bar(File&Edit&help)
examples (Menubar) • Steps to select “toolbox”: 1 - select view from menubar and then choose toolbox. 2 - Or you can choose direct from toolbar. • steps to select “project explore”: 1 -select view and then project explore. 2 - Or you can choose toolbox , then select icon of project explore. • Steps to select “addform”: 1 - select project from menu bar, and then choose addbar. 2 - Or you can choose toolbox, then select add form.
Terminology
ﺍﻟﺨﺼﺎﺋﺺ Properties • Properties list has a predefined value (numeric or string) and could be changed, some properties could be rewritten like caption, and some could be selected from option list by pressing on down arrow on the side. Others could be rewritten or by browsing the computer files when the user clicks on the dotted button on the right side a dialogue box appears. The browsing button appears when the user clicks inside the box. And the second part can predefined in the run time (using code).
Common properties ü Name : ”modify at design time”. and represent the name of the control (object) in the code. (choose name form properties window and modify it directly). ü this property used in the code to access to the properties , methods , event of the controls (objects). ü conditions used to modify the name : 1 - should not start with number(s). 2 - no longer than 40 characters. 3 - should not have space or symbol like (&, %, ? , *, $, # , etc. . ). 4 - should not booked up for the another control name (object) in the same form or another form ‘name at the same project.
Cont. Alignment : indicate the a place of the writing (Sentence or Word or number)in the box(example in the textbox tool). and have three options: 0 -Left Justify : ( Sentence or Word or number) appear in the left side. 1 -Right Justify: (Sentence or Word or number) appear in the right side. 2 -Center: (Sentence or Word or number) appear in the middle. ü : Appearance : indicate the shape of the objects. It have two options: 0 -Flat : make the shape of object flat. 1 -3 D: make the shape of object (3 d).
Properties of color backcolor &fore color. ü Back. Color : indicate the color of background for writing for example in the textbox or the background color of the form. there two type of color “stanadards inside the propertiesa window”: (system and palette) See figures below:
fore color • Forecolor: represent the Color of text written on ojects (form , toolbox). • Scorllbar contorl (in toolbox) dosen’t support the property of (backcolor and forcolor) because used standard colors coming from operating system in the Pc). • In the label tool, it cannot see any change in the property (backcolor ) except you modify the property of (backstyle to 1 - opaque). • Also for command button control (in toolbox), it should also change the property of (style to 1 - graphical) and will allow you to see the color modify in the backround of the command button. then change from design time or use code in the run time , for example: (command 1. backcolor=vbred).
Types of color • There are two general types of color: • Standard colors(in the properties window): during the design time can change it manually. • Custom colors: also called fixed colors. Custom colors can change during the run time (by using static code or functions of colors inside the code window).
fixed, functions, numerical fixed • Fixed code: the syntx is( object. backcolor=vbcolorname. Example (form 1. backcolor=vbgreen) Example (form 1. forecolor=vbgreen) • Functions: 1 - function of Qbcolor: the syntx is(Qbcolor(color number)): Example (text 1. Qbcolor=Qbcolor(5)). Example (text 1. forecolor=Qbcolor(5)). 2 - function of RGB: should indicate the color deeply when write the code. the syntx is (RGB(Red, Green, Blue). Example: form 1. backcolor=RGB(255, 0, 0). • Numerical fixed and hexadecimal value: there are 16 millions of colors. Example : text 1. backcolor=14232454 (numerical represent) Example : text 1. backcolor=&H 53 FF 2& (hexadecimal represent)
Form Border Style ü Form Border Style : using in the form , it help you to indicate the framework shape of the form and have many option: 0 - none : -None borderless and captionless. 1 - fixed single: a nonresizable form. 2 -Sizable: creates a resizable window. 3 -Fixed Dialog : non-resizable form without Minimize and Maximize buttons. 4 - Fixed Tool Window: bar form appear as small bar with small button of exit. 5 - Sizable Tool Window : bar form appear normal bar with small button of exit.
Tools Border Style, caption, control box ü Tools Border Style : for example (textbox, labelbox)box with border or box without border. 0 - None: without border. 1 -Fixed Single: with border. ü Caption: rename the object shape used in the design time. and also can change in run time by using code (object. caption=“name of object” ü : Control Box : if select (false), the buttons(closeminimize-maximize) of program will hide. Else select (true), the buttons come back to appear.
Demo Tool border style Caption property Forecolor /system Form border style Control box Forecolor /palette
Enable&font. ü Enabled : have (true and false), if the programmer select false, then (programmer will only use the tool(textbox as example) for opreation read. otherwise , if select (true) the programmer can (read , write, close form window) inside the tool(textbox as example). ü Font : It have five types: 1 -Font style: (italic, bold, regular, boldoblinque, etc). 2 -Font size: (8, 10, 12, 14, etc). 3 -Font name: ( times new Romans, Arial, etc) 4 -Font effect: (underline). 5 -Font script: (arabic).
Font • It can change the properties during the design time (manually). but because font exist inside dialog box in the code window(at run time), so we can coded it as some examples below : Text 1. fontname=“arial” (fontname) Form 1. fontsize= 13 (fontsize) Label 1. fontbold= True (font style) Text 1. Font. Underline = True (font effect) Text 1. Font. Strikethru = True ((font effect): use for make line on the text wrote inside textbox)). v One of the important properties of (font) is can able to copy the properties of one object to another object. for example: Label 1. font=label 2. font (font properties for label 2 will convert to label 1). ü This mean that (font property can use for two control (label 1, label 2). so if we going to change properties(font for label 2 ), label 1 will effect also. For example: Label 1. fontsize=20 / (here label 2 will also effect in the fontsize
Font (demo) Change properties of font in the design time Change the font properties using code at run time
Demo (using code to change font properties) Here we change the background of sentence in the textbox and also fonts(size=23, bold, underline, arial)
Enable property(demo) Enable property Select true, can read , press any buttons inside form 1 Select false , cannot press any buttons.
left, picture, right to left, Tapindex, Tapstop. ü Left: position of tool on the left border form. ü Picture: to upload picture inside the object. ü Right To Left: direction of writing from(left to right )or (right to left) and the script type(arabic, english, Latin). ü Tab. Index: movement between (objects)by using (Tap in the keyboard). ü Tabstop : stop movement (tap in keyboard will not active)
Tooltiptext, Top, Visible ü Tooltiptext: comment will appear above the tool when move the mouse just for a while. ü Top: position of object from the top border. ü Visible: indicate to show or hide the object. it has two case: True: show the object. False: hide the object.
Icon , Width, Height. ü Height: indicate the Height of object(contorl, form). ü Width: indicate the width of object (label, msgbox, form). ü Icon: add icon(image) to the form by browsing from computer and select image. icon height width
How to add icon to the commandbutton • First open vb • Second select from toolbox (command button) • Then change from properties window the (style form (0 -statndard to 1 -graphical). will allow your application to adapted the graphical (images). • Then select form properties (picture (image with extension (. ICO) , there are many images in the folder of vb inside your computer (vfp 98 then gallery then graphic) and then select on the image. ico, • Then add to the command.
demo
example (Design and simulation)
Mouse pointer & mouse icon property • They help you to indicate the shape of the mouse cursor. • Mousepointer offer (16) standard pointer provided by the opreating system as property to add to the object (form, text box as example).
Mouse pointer & mouse icon property • If the user desire to use special mouse pointer shape, then you can follow steps below(during the design time): 1 -Select from mouse pointer (99 -custom). 2 - select mouse icon from properties window and browsing the icon from your computer files(icon with. ico (extension)). v Image (icon) with extension. ico , you can get from the folder of your visual baisc in your desktop. there is file name(vf. P 98) , the select folder name (gallery), then you will see a lot of image with. ico
Mouse pointer & mouse icon property • OR (during the run time(using code) Write the code below. Syntx: mousepointer (standard ): Object. mousepointer=vb(hourglass, cross, etc). If you want specific mouse crusor icon: First : change mouse pointer to 99 -custom. Second : write the code for it: Syntx: object. mouseicon=loadpicture(“ path of icon insde your computer desktop”). Example : Command 1. Mouse. Icon = Load. Picture("C: Program FilesMicrosoft Visual StudioVfp 98GalleryGraphicsCLASSLIB. ico") Name of icon in folder
- Slides: 34