Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Zoom Function In VBA??

I am using a user form in excel. Is there a way that I can create 2 buttons for zooming? One with a "+" to zoom in and one with a "-" to zoom out. If so, how would I write the code for that?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Zoom In Function
i want to add a zoom in function into the program.
how can i make it?
is it change the scale of the picturebox~?

Zoom In Function (2d Graphic, ZoomIn By Changing Location And Size Values)
im looking for a way to preform Zoom In option in my game.
ok, so i got those objects i call Layers, that are things that suppose to be painted on the screen in a loop (it's to make 3d effect for 2d graphic so that what closer to the screen will hide things behind him)

i have the following integers / long :

Width (the width of the object that gonna be painted)
Height (guess what it does...)
ZoomIn (the zoomIn level)

what i basicly wonna do is to enlarge everything base on the zoomIn value, but to keep stuff in their right location based on the middle of the screen (what's in the middle will stay in the middle, and things on the edges of the screen will be painted outside it and wont be shown).
Also, i must keep the distans between the objects in right propution, or some things might be painted over things they dont suppose to touch.

i tried few things, but i cant find the right equation for it.

anyone knows? thanks.

Zoom In/Zoom Out Image Option...
In my application I display a small image in the image box and also
have a command button near it. I want an option to zoom the image in
a separate form.

How to zoom the image? Can I integrate any image enhancement feature?

Zoom In And Zoom Out Of A Image In Picturebox
Need help in trying to figure out how to zoom in and out of a image inside of a picturebox... can someone help?

A Better Way To Zoom In DX7?
I would realy like to be able to use zooming in my program but the blt method for zooming is very slow. I made my own zoom Blt function that uses GetLockedArray to copy the surfaces but this is only at least 28% faster and takes up to about 1400ms with both video and system memory. Then I desided to set it up so that I could draw every pixel, every 4th pixel, every 9th pixel, every 16th pixel, and etc... Then I could offset the pixel I am drawing so I could draw the intire thing but not all at once. This works but its very hard to work with and it has some limits.

What Im asking if anyone knows a better way. Ive considered D3D but Im not to shure how fast It would be to use a 3d object in place of a surface. Ive heard people talk about doing this for DX9 since it isnt made to work with sprites. The only problem I can think of is that placing the image as a texture on a 3d object could be slow or look bad.

I already know a little about D3D but not enough to do this yet. Any thoughts?

Zoom Out/in
Hi all,
Below is an animation..A bird is flying..what I am tring to do is to make the bird flying away by getting the image size smaller and smaller using timer event...What Am I doing wrong ?

PHP Code:

Private Sub Timer1_Timer()
Static bird As Boolean
bird = Not bird
If bird Then
aaa.Picture = bbb.Picture
aaa.Picture = ccc.Picture
End If
aaa.Left = aaa.Left + 20
aaa.ScaleWidth = aaa.ScaleWidth - 1
aaa.ScaleHeight = aaa.ScaleHeight - 1
 End Sub 

Can I somehow zoom my picture (it's the picture in another picture box)...anybody knows code for that

How To Zoom ?
I use picturebox. How I can zoom in and zoom out when I draw rectangle within the picturebox?

Need Help With Zoom
Is there any way to zoom in on a picture box where I click the mouse, instead of zooming into the center of the picture box.

Zoom In And Zoom Out
how to write the code to zoom in or zoom out the picture? can anybody provide the code on zoom in or out function?

Zoom Out?
Hi all,
Below is an animation..A bird is flying..what I am tring to do is to make the bird flying away by getting the image size smaller and smaller using timer event...What Am I doing wrong ?

VB Code:
Private Sub Timer1_Timer()Static bird As Booleanbird = Not birdIf bird Thenaaa.Picture = bbb.PictureElseaaa.Picture = ccc.PictureEnd Ifaaa.Left = aaa.Left + 20aaa.ScaleWidth = aaa.ScaleWidth - 1aaa.ScaleHeight = aaa.ScaleHeight - 1 End Sub

What Is Zoom Doing ?
When an app, like excel for example, allows you to zoom in/out, what is it actually changing - resolution, dpi ??

'zoom' RTB?
is there a way to scale a Rich text box so you can adjust the number of lines you see in the box regardless of the font setting and still be able to edit the text. Like 'view -> zoom...' in Word...

Any suggestions?


Pls Help With Zoom !!!!!
hi there............i am not able to progress in a right diirection regarding the zoom feature where i hv to select a portion of analog wave displayed in a picture box,i hv added to my project....i am explaining what ive done so far..............
i was trapping the co-ordinates of mouse down and mouse up event to select he portion of displayed wave and then comparing it with the values in the file from where the the wave was originally drawn.I was using rubberband effect to select the portion but since mouse down event was trapped visibly no selected porttion was visible........i am sure there is a sophisticated way to go about it.......someone of u suggested bitblt or strechblt function but i am not able to incorpoprate it..............ill b thankful if any one of U can show me the right path..........possibly witn a piece of code as an example or need of an quick reply.............thx!

Hello there, I was asked to make a program to zoom a picture based on an algorithm given by my professor.

The real problem here is that I have to get the array of Bytes of a picture, then manipulate them to get a new array of Bytes and then place this array in a picturebox...

I know how to get the array of Bytes from a PictureBox but I do not know how to Put an array of Bytes into a picture box... Could somebody tell me how to do this?

I also need to know on which pixel the user is clicking so I can know the area I am going to zoom in.

Other ideas are welcomed...

Thanks in Advance

Zoom In An Out!
Could someone please help me by telling me how i could zoom. Here's my situation: i have got an image in a picture box and i want to be able to zoom in and out through my program.

Zoom In/out
Hi, how is posible zoom in or zoom out image from picture box control

have anybody vb code?


i'm new to this, and i'm trying to build a program that draws lines on a map, based on what coordinates you put in, and lets you zoom in on any part of the map when you click on it. i have the drawing part down, but the problem i'm having is when i click on the map, i cant seem to get it to zoom in. if anyone knows how to do this, it would help me out greatly.

I Need A Zoom In, Zoom Out Pic
All I need is a zoom in pic and a zoom out pic for my toolbar. Does anyone have any or would like to draw one up. I am horrible at making pics. The ones that I found on my pc look horrific. Thank You

First, I'd suggest the image control instead of the picture box.
1) Put a frame with no border on your form.
2) Place an image inside the frame.
3) Set the imagecontrols "stretch" property to TRUE.
3) When the user clicks the button, enlarage the imagecontrol, and set it's "top" and "left" properties so it shows the correct part of the picture.

Should work...


How To ZOOM In/out???
Anyone know a simple way to Zoom graphics in a picture box in and out. Maybe an .OCX that does it for you?? All suggestions appreciated!


I use PaintPicture method to zoom-in the image, but when I zoom-in more and more, the pixel color change, how to smooth the image after zoom-in ??

thanks and regards,

i've asked this question on other website,but i still can't get a good,i think maybe vbcity can help me.

here's my problem:
i draw some curves in picturebox(picture1.pset or picture1.line),and now i hope if i roll the mid-button,the curves will zoom in or zoom out at the same time.

hope i have made myself clear...

Zoom Zoom Zoom......
I have posted a few threads over the past few days in a vain attempt of solving a small problem I am having. However, I have gotten nowhere. As a result, I am going to post what I am directly trying to accomplish. So, PLEASE, any help would be greatly appreciated.

In the attached project, I would like it so when the user clicks once on the form, the zoom window will stop following the mouse and the zoom image will become static. However, I would like the user to still be able to turn the grid on/off and to also be able to zoom in/out of the static image.

It sounds quite simple, but it is really quite complex. This whole area is new to me, and I've been trying to figure it out forever, and I am simply growing frustrated.

Edited by - Marce22 on 10/29/2005 7:30:59 PM

Zoom In/out : Help Please

I want to Zoom-in / Zoom out a picture , as well as the picture
should be scrollable.


Zoom In/out : Help Please

I want to Zoom-in / Zoom out a picture , as well as the picture
should be scrollable.


We are trying to develop an ActiveX control, which draws lines,points etc. As a part of this ActiveX control we want to provide the Zoom functionality, when the user drags a rectangle. We are using Picture Box control of VB to display the graphics.When we drag the rectangle we find the objects streched after zooming.
Please Help.


I want to zoom a image in picture box. Either i can zoom to particular levels or click & drag a window in the picture box, which maximizes the selected (picked) image.


Zoom Problem

I'have search in any corner of Internet without finding any help.. so hope someone can help me.

The problem is simple... i'm trying to develop an application to make label. I need to implement th Zoom (like in MS Word to watch document closely)

I have attached an example wich demostrate my problem... when i zoom in or zoom out the distance between the three squares do not remain the same....

What i mean:

At 100%
first square dist 1 px from second square and second square dist 1 px from the third square...

At 125%
first square dist 1 px from second square while second square dist 2 px from the third square... why ?

and so on...

Hope anybody can help me !!!

I will print an image much smaller to the printer. Printer.Zoom = 25 should be working. But all I get is 100 %. What should I do ?

Graph And Zoom
hi all,
i want to know is there a zoom function for mschart? if no, what are available for me to draw graph with zoom in/out capability. i found some but require to pay. i want a free one.

Picture Box Zoom
I was wondering if anybody knew how to zoom up into a particualr area of a picture. For instance the user sees a picture in the form and upon moving their mouse over a particular spot the user can press down or up to zoom in/zoom out on that spot. I want the picture box to remain the same size so upon zooming in on the desired location the image is croped. Does anybody know how to do this?

as always thanks in advance

Zoom Slider

I have a Picturebox (PicBox1) and an image box (imgMap),

How is it possible to have a slider under an image (a map) so that when the slider is moved right the image is zoomed into, the further you slide the further it zooms into the image and backwards to zoom out?

I also need to be able to drag the image around freely in the Picture box.

Thank you for any help on this.

Zoom Map Of America
Hi there
In Microsoft's MapPoint a user can click on a map of North America and drill down, all the way form states to city to towns and to streets, any where in the US. Is there a free .ocx or something that will allow me to do the same thing in a program I want to write?
I have seen a company by the name of ESRI have something out that might do this but they want over $400 for it. I cannot afford this price. So I am looking for something that comes with a simple couple of zoom buttons (In and out). I will appreciate any info you guys can give on this matter

Pan&&Zoom Picture
Hi to all and sorry for English.
I have a problem with a code for pan and zoom picture.
The goal is to zoom and pan Picture maintain Aspect ratio in a
Picturebox that had fixed size.

In my code i can Drag on picture (once zoomed) with Left Button
to Scroll and Drag Left and Right with Right Mouse Button to Zoom Picture.
The aspect ratio is preserved and the image centred in Picturebox.

If the image size is different from Picturebox size,I would like that during
zoom, the image went to fill the whole Picturebox available space.

Please help me.

Thanks for time

Best regards

Enclosed vb project sample

Picture Zoom
hi everone again;
how can i zoom image in picturebox in vb.(like 1x,2x,3x......) i load the picture in picturebox and if push the command button picture is closing but no changing picturebox border.please help me

Problems With Zoom
I'm currently creating a program that will allow a user to locate an image file from their system by using a common dialog. This image will then be resized to smaller dimensions so that it will seem to appear as a thumbnail.

The setting for the form is that i have two image boxes. the first image box being set as hidden but this box to be used to retrieve the orignal size settings. after all calculations have been done the new smaller image is then transferred to the second image box.

So far i have got all this done but the next stage requires that whenever a thumbnail has been double clicked it the image box that contained the orignal image at it correct size would be shown. with this image a scrollbar would be available to allow for the user to zoom into the picture. Below is the code that i have used to create the zoom function: -

Private Sub hsbZoom_Scroll()

imgZoom.Stretch = True
imgZoom.Height = (ImgMain(ITB).Height / 100) * (hsbZoom / 25)
imgZoom.Width = (ImgMain(ITB).Width / 100) * (hsbZoom / 25)

The problem that i have been having with this code is that when i select another thumbnail and view it in it's orignal form with the zoom feature still available the settings from the previous image are still set

e.g. if i tried to zoom into a long narrow image and then decided to view a image that was set as landscape the landscape image will appear long and narrow.

Another problem that i have been having it that when i zoom into a image it zooms into the top left of the corner rather than the middle. i am very new to VB and will appreciate any help.


I have included my program to help explain my problem.


Need Help In Zoom In And Out Coding
Anyone knows how to do a zoom in and out button for a picture?

Zoom Chart
I have got several chart in a page. I would like to write a macro that zoom on a particular graph if I click on it.

Thank you for your idea.

VB 6 DataReport Zoom

I have a data report in my VB6 app which I open up through code. This works fine but the report opens up with a zoom level of 100%. I want to be able to open the report to 75% or maybe "fit to page" automatically as the bottom of the report is hidden under 100% zoom.

Is there an easy way to set the zoom level?


Private Sub cmdPrint_Click()
On Error GoTo Err_Print_Click
Dim Msg, Response, Title, Style As String
Dim i As Integer

With envData
End With

If optScreen = True Then
With XAM7000Report
.Orientation = rptOrientPortrait
.Visible = True
End With
End If

Select And Zoom
I have 2 command buttons:
one for selecting the area and other is the zoom button
After the user select the area by dragging the mouse area the picturebox, he then click on the zoom button to zoom on the selected area....
I can now select the area but how can I implement the zoom function in?

Owc11 Zoom, Pls Help
in the attached pic, it is a graph that i use owc11 components to create.
now i want to add in features like zoom into certain part of the graph to have a clearer view. i went through the owc11 programming help file created by microsoft, but it is not very helpful.

can anyone, teach me how to do it , or show me some sample or info to look at.


Zoom Problem
The problem is that when I try and zoom in at half the picturebox disapears. I have no clue what is wrong. I mean isn't half the same
as x0.5?

Private Sub mnuZoomHalfx_Click()
CMap.Zoom = 0.5
picMap.Width = ScaleX(CMap.TileWidth * CMap.MapTileX, vbPixels, vbTwips) * CMap.Zoom
picMap.Height = ScaleY(CMap.TileHeight * CMap.MapTileY, vbPixels, vbTwips) * CMap.Zoom
curMap.Width = CMap.TileWidth * CMap.Zoom
curMap.Height = CMap.TileHeight * CMap.Zoom

mnuZoom1x.Checked = False
mnuZoom2x.Checked = False
mnuZoomHalfx.Checked = True

DrawBlocked CurrentLayer
End Sub

Tablet PC Zoom
Hi all,
I am writing an application to run on the TabletPC
I am loading an image into the background of the inkPicture control (TabletPC SDK control). I am able to draw onto the picture, but when the picture loads, it is too big. I am wanting to view the image in a readable size like the way that Windows Journal is able to display an image. I believe they call it 'reading view'. I have found some code to do this in the manner that Journal does using the following that I downloaded from

void ScaleProportionally(Graphics g, Image i, Rectange r)
float width = i.Width / i.HorizontalResolution;
float height = i.Height / i.VerticalResolution;
SizeF sizef = new SizeF (width, height);

float scale = Math.Min(r.Width / sizef.Width, r.Height / sizef.Height);

sizef.Width *= scale;
sizef.Height *= scale;

g.DrawImage(i, r.X + (r.Width - sizeF.Width) / 2,
r.Y + (r.Height - sizef.Height) / 2,
sizef.Width, sizef.Height);

I am trying to change this code into something that will work in vb6.

I created the ScaleIt function to simulate the Math.min function. From what I have read on the Min function, it is passed in 2 numbers and it will return the lower of the 2 numbers.

So far I have the following:

Private Sub ScaleProportionally(i As StdPicture)
Dim lwidth As Long
Dim lheight As Long
Dim Width As Single
Dim Height As Single
Dim Scal As Single

lwidth = ScaleX(i.Width, vbHimetric, vbPixels) 'Getting the resolution
lheight = ScaleY(i.Height, vbHimetric, vbPixels) '

Width = i.Width / lwidth
Height = i.Height / lheight
Scal = scaleIt(Picture1.Width / Width, Picture1.Height / Height)

Width = Width * Scal
Height = Height * Scal

' Here is where I am lost
End Sub

Private Function scaleIt(w As Single, h As Single) As Single
If w < h Then
scaleIt = w
scaleIt = h
End If
End Function

The Picture1 is a container for the Inkpicture1 control.
The inkpicture1.picture is what is being passed into the sub.
Should I be using bitblt to repaint the image or is there a vb6 equivalent to .Net's DrawImage? I hope that this is in the right forum as I was unsure about putting it in the .net forums because I am trying to convert it into vb6 code.

Any help on this is greatly appreciated.



Datareport && Zoom
Can we specify the zoom before showing datareport ? in some cases it could be nice to "well size" the report in it (depending of what it contains).
Thanks for advises, answers.

Fast Zoom
..? Sir,

i've a code which Zoom into the PicBox image using StretchBlt.
It works fine when images are NOT big, but when i load a 2500 x 2900 pixel image it doesn't show anything.

Also i'm looking for something FASTer ...

Do you have any idea how to do it, maybe using GDI+ ?

Thanks for your help !

Picture Zoom
I want to make a program that is able to Zoom pictures in and out (perhapes in a picture box?)
Is there an API call that allow me to do this? If it is possible how?

Tnx in advance

Can I Zoom In On An Image?
I am creating a photo viewer and want to be able to hover the mouse over an area of the screen which contains a jpeg and for a small window to show say X2 zoom of that area.

is this at all posible, how woudl i go about it>? any good tutorials you can point me to>?

Copyright 2005-08, All rights reserved