A Couple Visual Basic Questions

Started by
11 comments, last by rapidarp 19 years, 12 months ago
I''m working on a small program in Visual Basic. It contains the maps for three small cities. The user can click a button, with the appropriate City''s name on it, and it opens another window with the map of the city. That window has a scroll bar so incase the screen resolution is tool big (or small), the user can scroll. Question #1. - How do I go about getting the scroll bars to work and scroll properly? Question #2. - On the main program window, I have a button where the user can change the program''s color depending on wether or not it''s Day or Night. Daytime colors are standard (grey and blue) and nighttime colors are red (text) and black (background). How can I make it so when the user clicks the button, it switches back and forth between the color settings? Any help would be greatly appreciated. Thanks.
Advertisement
Hi,

Question 1: Use the Horizontal and Vertical Scroll bars to alter the top and left of the picture box - I assume you are using a picture box for the picture - and set constraints depending on the size of the picture compared to the screen resolution.

Question 2: Just use form.backcolor = &H0etc (a long value for the color) and the same with the text (forecolor I think - it has been a while since I used VB!)

I assume you are new to programming, it would be better if you said what exactly what you mean by map - is it a picture or a load of shapes on the form?

Good Luck anyway!
By "map" I mean a picture (.jpg or .bmp) that shows streets and stuff for a city.
Well yeah, try what is said in the above, above post! about moving the picture around. I think one of the Win32 API functions will allow you to find the current screen resolution, and if you know the size of the picture that is easy to sort. I am not sure what you mean by the program text - do you mean on the picture or just in general - if it is the latter use backcolor!

Good Luck
First off, this program is being developed for the use of my local police officers (whom I volunteer with). The problem I ran into a while back when I first started this program was that the resolution on their laptops (in their patrol cars) was like 600x800 (i think) and that cut off the window that contained the map (picture). I wanted to use scroll bars so when this happens, they can still view all parts of the map.

Is there something I can do to make all the windows conform to their resolution and not get cut off?
If you have a picture box and a horizontal and vertical scroll bar on the form, use:

Private Sub Form_Load()
VScroll1.Max = (Form1.ScaleHeight - Picture1.ScaleHeight)
HScroll1.Max = (Form1.ScaleWidth - Picture1.ScaleWidth)
End Sub

Private Sub HScroll1_Change()
Picture1.Left = HScroll1.Value
End Sub

Private Sub VScroll1_Change()
Picture1.Top = VScroll1.Value
End Sub

to move the picture around. You could design the system so the windows are always fixed at a size that suits the computers. That is the most simple way to do it. Then using scroll bars you can always find your way around - it will necessitate their use though - the other ways are much more complex and there doesn''t seem to be the need for that.

Good Luck
I used your code and it compiles but then it only lets me view the picture the same size as the picture box. I want be able to scroll through the entire picture within the pic box.

Hope i''m not loosing you.
I would make it detect arrow keys to move it. I dunno the mouse functionality of a cops laptop.
If I think I understand what you mean, try change the AutoSize option of the picture box on the properties menu to true - then the picture box will automatically take the size of the picture.

Erm think that is what you mean!

Hope it works
Ok, lemme see if i can explain this....


I loaded my picture into the picture box.
When I scroll (using ur code from above) it doesn''t show the whole picture; just what the size of the picture box shows.

I want to be able to scroll and see the entire picture within the picture box.

lol.....this is hard to explain.


Also, I got everything to change colors when u click the Day/Night button, but how do I get it to change back to normal colors?


I apologize for all the questions. I haven''t used VB in a long time.

This topic is closed to new replies.

Advertisement