rround
asked on
Vertical scrollbar with picturebox in VB3
I have a picturebox which takes input from a variable length file (the picturebox height increases as the information is read in from the file, the width always remains the same). I have to alter the vertical scrollbar after the picturebox is displayed so that all of the information in the picturebox can be viewed.
The problem is it either scrolls too much past the end of the picturebox, doesn't scroll enough or gets an error because the value is too high.
This is what I have been using;
vscroll1.max = picture1.height - scaleheight
vscroll1.top = -vscroll1.value
plus I have been using many other variations for several hours and can't seem to get the desired results.
The problem is it either scrolls too much past the end of the picturebox, doesn't scroll enough or gets an error because the value is too high.
This is what I have been using;
vscroll1.max = picture1.height - scaleheight
vscroll1.top = -vscroll1.value
plus I have been using many other variations for several hours and can't seem to get the desired results.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
VScroll1.Max is limited from -32,768 to 32,767, inclusive.
So you should fix the VScroll1.Min=0 , VScroll1.Max=32000 and compute the values of VScroll1.LargeChange, VScroll1.SmallChange and VScroll1.Value accordingly to your effective size.
So you should fix the VScroll1.Min=0 , VScroll1.Max=32000 and compute the values of VScroll1.LargeChange, VScroll1.SmallChange and VScroll1.Value accordingly to your effective size.
ASKER
Ameba,
This still doesn't work. I had already tried most of code in your suggestion but on the larger pictureboxes, it doesn't scroll far enough to reach some of the information, and on smaller pictureboxes, it scrolls too far.
Chabaud,
I think I must be missing something in calculating the effective size. The Scaleheight is 7215 twips. Now, If I have a picturebox and its final size is 41885, then I should have:
VScroll1.Max=picture1.heig ht-scalehe ight
Picture1.Top =-VScroll1.Value
right? But using this, the bottom of the picturebox is missing. When the final size is only 11985 then the scrollbar scrolls way past the bottom of the picturebox. The problem is, each time my app runs, the size of the picturebox will vary. What am I missing to make this work?
This still doesn't work. I had already tried most of code in your suggestion but on the larger pictureboxes, it doesn't scroll far enough to reach some of the information, and on smaller pictureboxes, it scrolls too far.
Chabaud,
I think I must be missing something in calculating the effective size. The Scaleheight is 7215 twips. Now, If I have a picturebox and its final size is 41885, then I should have:
VScroll1.Max=picture1.heig
Picture1.Top =-VScroll1.Value
right? But using this, the bottom of the picturebox is missing. When the final size is only 11985 then the scrollbar scrolls way past the bottom of the picturebox. The problem is, each time my app runs, the size of the picturebox will vary. What am I missing to make this work?
Why don't you use
ScaleMode = vbPixels ' 3
Your form scaleheight will be 7215/15 = 481
Your file value 41885 will be 41885/15 = 2792. By deviding by 15 you will not reach scrollbar limit of 32767 too soon.
ScaleMode = vbPixels ' 3
Your form scaleheight will be 7215/15 = 481
Your file value 41885 will be 41885/15 = 2792. By deviding by 15 you will not reach scrollbar limit of 32767 too soon.
ASKER
Ameba,
This still doesn't work. I had already tried most of code in your suggestion but on the larger pictureboxes, it doesn't scroll far enough to reach some of the information, and on smaller pictureboxes, it scrolls too far.
Chabaud,
I think I must be missing something in calculating the effective size. The Scaleheight is 7215 twips. Now, If I have a picturebox and its final size is 41885, then I should have:
VScroll1.Max=picture1.heig ht-scalehe ight
Picture1.Top =-VScroll1.Value
right? But using this, the bottom of the picturebox is missing. When the final size is only 11985 then the scrollbar scrolls way past the bottom of the picturebox. The problem is, each time my app runs, the size of the picturebox will vary. What am I missing to make this work?
This still doesn't work. I had already tried most of code in your suggestion but on the larger pictureboxes, it doesn't scroll far enough to reach some of the information, and on smaller pictureboxes, it scrolls too far.
Chabaud,
I think I must be missing something in calculating the effective size. The Scaleheight is 7215 twips. Now, If I have a picturebox and its final size is 41885, then I should have:
VScroll1.Max=picture1.heig
Picture1.Top =-VScroll1.Value
right? But using this, the bottom of the picturebox is missing. When the final size is only 11985 then the scrollbar scrolls way past the bottom of the picturebox. The problem is, each time my app runs, the size of the picturebox will vary. What am I missing to make this work?
You must also remove the scrollbar height if you want the bottom of picture to match with max of the scrollbar:
VScroll1.Max=picture1.heig ht-scalehe ight-VScro ll1.heigth
VScroll1.Max=picture1.heig
ASKER
Ameba,
This still doesn't work. I had already tried most of code in your suggestion but on the larger pictureboxes, it doesn't scroll far enough to reach some of the information, and on smaller pictureboxes, it scrolls too far.
Chabaud,
I think I must be missing something in calculating the effective size. The Scaleheight is 7215 twips. Now, If I have a picturebox and its final size is 41885, then I should have:
VScroll1.Max=picture1.heig ht-scalehe ight
Picture1.Top =-VScroll1.Value
right? But using this, the bottom of the picturebox is missing. When the final size is only 11985 then the scrollbar scrolls way past the bottom of the picturebox. The problem is, each time my app runs, the size of the picturebox will vary. What am I missing to make this work?
This still doesn't work. I had already tried most of code in your suggestion but on the larger pictureboxes, it doesn't scroll far enough to reach some of the information, and on smaller pictureboxes, it scrolls too far.
Chabaud,
I think I must be missing something in calculating the effective size. The Scaleheight is 7215 twips. Now, If I have a picturebox and its final size is 41885, then I should have:
VScroll1.Max=picture1.heig
Picture1.Top =-VScroll1.Value
right? But using this, the bottom of the picturebox is missing. When the final size is only 11985 then the scrollbar scrolls way past the bottom of the picturebox. The problem is, each time my app runs, the size of the picturebox will vary. What am I missing to make this work?
ASKER
Thanks Ameba,
I finally got it working....I was having a major brain cramp over this and I knew it should be relatively simple.
Thanks again.
Rob.
I finally got it working....I was having a major brain cramp over this and I knew it should be relatively simple.
Thanks again.
Rob.
ASKER