• Like
  • Save
Image contro, and format functions in vb
Upcoming SlideShare
Loading in...5
×
 

Image contro, and format functions in vb

on

  • 29,873 views

 

Statistics

Views

Total Views
29,873
Views on SlideShare
29,767
Embed Views
106

Actions

Likes
0
Downloads
9
Comments
0

10 Embeds 106

http://visual-basic-adk.blogspot.in 61
http://visual-basic-adk.blogspot.com 22
http://visual-basic-adk.blogspot.com.br 9
http://visual-basic-adk.blogspot.kr 5
http://visual-basic-adk.blogspot.co.uk 4
http://visual-basic-adk.blogspot.sg 1
http://visual-basic-adk.blogspot.it 1
http://visual-basic-adk.blogspot.nl 1
http://visual-basic-adk.blogspot.cz 1
http://visual-basic-adk.blogspot.mx 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Image contro, and format functions in vb Image contro, and format functions in vb Presentation Transcript

    •  Image Control Pictures Box Adding A Picture Box To A Form Setting Or Getting The Picture Adding Text to a Picture Box Formatting Text In A Picture Box Handling Picture Box Events Drawing Lines And circles In A Picture Box Picture box animation Copying Pictures To And Pasting Pictures From The Clipboard Differences between Image and picture box controls Formatting Function
    •  Image Control is used to display the images. The image control also support the property of Stretch. When Strech propery is false It will automatically resize.
    •  When stretch property is set to true it will fit the image in image control box.
    •  Pictures Box are more complete controls than image controls. It is used for graphics and you can load images into a picture box. When you load an image into a picture box the picture does not resize itself by default to fit the image as the image control does but it will if you set its AutoSize property to True.
    •  Select the picture box tool on the toolbox and double click it to add a picture to your form. If you want the picture box to resize itself to fit the picture you will load into it , set its auto size property to true. If you don’t want a border on the control set its border style property to none. You can load the picture with two different ways:- At design time:- select the picture property and choose image.s
    •  At run time:- Create a command button and click on the picture property and load the image. Private Sub Command1_Click() Picture1.Picture= LoadPicture("C:UsershpDesktopLighthouse.jpg") End Sub
    • • If you want to get the picture in a picture box, you also use the picture property.• For example:-Here we copy the picture from picture1 to picture2 when the user clicks a command button: Private Sub Command1_Click() Picture2.Picture = Picture1.Picture End Sub
    •  You draw text in a picture box with its Print method passing that method the text you want to print. Where does that text appear? It appears at the location set by the picture box’s currentX and CurrentY properties. Private Sub Form_Load()Picture1.ScaleMode = vbPixelsPicture1.CurrentX = 30Picture1.CurrentY = 25Picture1.Print ("It is displaying a content in picture box")End Sub
    •  You can use format text in a picture box using the fontbold , fontitalic ,fontunderline properties. When you set a property to true that property applies the next time you use the print method in the picture box.
    •  Private Sub Form_Load()Picture1.ScaleMode = vbPixelsPicture1.CurrentX = 30Picture1.CurrentY = 25Picture1.Print ("It is displaying a content in picture box")Picture1.CurrentX = 30Picture1.CurrentY = Picture1.CurrentY + Picture1.TextHeight("")Picture1.FontUnderline = TruePicture1.Print ("It is displaying a content in picture box")End Sub
    •  The click event is useful if you want to use picture boxes as sort of image bearing buttons. If you want to know where in a picture box the user clicked the mouse use mousedown.
    •  Private Sub Form_Load()Picture1.ScaleMode = vbPixelsPicture1.CurrentX = 25Picture1.CurrentY = 20Picture1.Print ("Picture Box")End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If X > 16 And X < 83 And Y > 11 And Y < 36 Then MsgBox "you clicked the word ""picture""" End If If X > 83 And X < 125 And Y > 11 And Y < 36 ThenMsgBox "you clicked the word ""box"""End IfEnd Sub
    •  In a Picture Box you can draw lines and circle and set points to particular colors in a picture box. To Draw Circle Private Sub Command1_Click()Picture1.Circle (700, 800), 500, vbRed End Sub To Draw Line Private Sub Command2_Click()Picture1.Line (1500, 1000)-(2500, 1000), vbRed End Sub
    •  1.Select the Project Components menu item. 2.Select the Controls tab in the Components box. 3.Select the Microsoft Windows Common Controls item in the Components box and click onOK to close that box. 4.Add a new image list control to your program using the Image List tool in the toolbox. 5.Right-click the new image list control and select the Properties item in the menu that opens.
    •  6.Click the Images tab in the Property Pages box that opens, and load the images you want touse in the image list using the Insert Picture button. 7.Close the Property Pages box by clicking on OK.All that remains is to add the code you need. For example, here we’ve added a timer control, Timer1to the program, set its Enabled property to False, and set its Interval property to 1000 .
    •  You can copy the images to the clipboard , letting the user paste them into other programs. To place data in the clipboard you use Setdata() , and to retrieve data from the Clipboard you use getdata().
    •  Private Sub Command1_Click()Clipboard.SetData Picture1.PictureEnd Sub Private Sub Command2_Click()Picture2.Picture = Clipboard.GetData()End Sub
    •  As they change shape, image controls stretch the image they contain. Picture boxes and forms do not. Image controls are lightweight controls. This means that an image control will consume less memory and is faster to deal with than picture boxes.
    •  Graphics methods which allow you to draw graphics on the fly at run time, can not be used to draw on image controls but they can draw on top of picture box controls. A picture box’s can be used as container objects. This means other objects can be drawn and grouped inside them.
    •  The way a value is printed or displayed is called its formatting. Format Number Format Currency Format Percentage Format Date Time
    •  This function formats the number to two decimal places with commas.Syntax:- Formatnumber(number)Example:- formatnumber(87321.784)Output:- 87,321.78
    •  This function formats a number as currency such as dollars and cents. The number will also include a dollar sign or other currency symbol.Syntax:- Formatcurrency(number)Example:- Formatcurrency(2384921.387)Output:- “$2,384,921.39”
    •  This function format its numeric argument as percent.Syntax:- Formatpercent(number)Example:- Formatpercent(.784)Output:- “78.40%”
    •  This function takes a date datatype argument and format it in various ways.Syntax:- FormatDateTime(DateExpression [,Format])Example:-FormatDateTime(now , vblongdate)Output:- “Wednesday,september 5,2012”