Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

rapidarp

A Couple Visual Basic Questions

This topic is 5174 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I would make it detect arrow keys to move it. I dunno the mouse functionality of a cops laptop.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!