Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help with visual basic animation

Status
Not open for further replies.

Christy

New Member
Hey Everyone,
please find attached,
Please can someone help me with this visual basic animation homework.I have tried but I'm not getting it right.

Will be appreciated.Thanks
 

Attachments

  • Tut8.doc
    60.5 KB · Views: 352
Hey Everyone,
please find attached,
Please can someone help me with this visual basic animation homework.I have tried but I'm not getting it right.

Will be appreciated.Thanks

hi,
Can you post the program you have written thats giving you a problem.?
 
Hi eric, My program was saved onto my flashdisk but I have lost it ealier today at one of the lecture halls at my university...but it was not much code i have written....i have a problem on where to start.
 
Just for my own curiosity which version of VB?

Ron
 
Thanks Christy. Years ago I did a few similat projects using shapes and fill. They were done in VB 6.0 :)

While I have VB 2010 (I think) or maybe the 2008 version I have never done much of anything using it. Thus I was just curious as to the version you were using. Eric is quite good with VB and may have some good useful information for you.

Thanks
Ron
 
You welcome...Animation of VB for me is a bit tricky.But thanks for the concern.I'm sure Eric would give me some good information then.
 
Christy! there is an image array tool in VB you can call the images one by one by index, I use this all the time (combined with a timer ) you can get really smooth results.

Trouble is most of my code is written with VB6! Its quite easy to convert though.

I haven't got a version of VB 2010 as I now use C#.

Cheers Ian
 
Hey Ian, thanks for letting me know about about the image array tool which I wasn't aware of.If I understand you correctly,have you done the code for my question i asked for help with already with VB6?Or are you just letting me know that it is easy to convert from VB6?
Thanks
 
You welcome...Animation of VB for me is a bit tricky.But thanks for the concern.I'm sure Eric would give me some good information then.

hi Christy,
In VB
Start a new project.
Place a Picture box component on the Form, make it about 10cm square

Place a Shape1 component in the Picture box, make the shape1 Rectangular, fill style Solid, fill with a dark colour, say Green for 'water'
Adjust the shape to represent the tank, about 2cm wide, 5cm high.
If necessary, send the tank box to the back, use the menu to do this.

Place a second Shape2 at the top of the tank, adjust the shape height so its just covering the inside edge of the tank shape, size about 2cm wide and 2 mm high
Set the fill style to solid and make the fill colour say blue for 'air' [ above the water]

Place a timer component on the Form, set timer to enabled, interval say 50msec.

option explicit
Dim Water as integer

<type inside the Timer procedure.>

Water = Water+5

Shape2.Height = Water

'' this will increase the height of the 'air' shape rectangle so it will appear that water level is falling.

When you run this simple program the water level in the tank will appear to fall.

You should be able to use a Frame for the IN valve radio button options,
likewise for the OUT valve

You would test in the Timer proc, the IN/OUT buttons and either INC or DEC the Water variable, so the tank would appear to fill or empty.

Use a Horizontal Bar to adjust the Timer interval.

This is enough to get you started....:)
 
Hi Eric,
Thanks,I have already started way before you replied.I dont know if the concept I'm using is the same as yours.What I did was, I made a picturebox the shape of a tank and changed the backcolor of the picturebox to a solid blue. Then i filled half of the the tank with white as if the tank is half full,so I can vary the size of the white shape as if the water is falling or rising.Is it the same concept as yours?I have gone so far as to where if the oultet open button is pushed, the size of the white increases and making it seem the water is decreasing.With use of the timer.
 
Hi Eric,
Thanks,I have already started way before you replied.I dont know if the concept I'm using is the same as yours.What I did was, I made a picturebox the shape of a tank and changed the backcolor of the picturebox to a solid blue. Then i filled half of the the tank with white as if the tank is half full,so I can vary the size of the white shape as if the water is falling or rising.Is it the same concept as yours?I have gone so far as to where if the oultet open button is pushed, the size of the white increases and making it seem the water is decreasing.With use of the timer.

hi,
Thats a good starting point.
The way I read the question paper, is that the Picture box would be used for all the components.???

Give my simple version a quick try, it leaves the main picture box free for adding the valve components.

You will also need to add to the Timer Proc, end stops for the water min/max levels.
 
Morning Eric & Christy (My Morning :) )

Eric, please correct me if I have this wrong but the Shape component is not in the toolbox for the newer versions of Visual Basic. I believe Visual Basic 6.0 was the last version that used Shape. Starting with Visual Studio versions around 2003 (VB 2003) the Shape was gone. I don't think you can have for example Shape1, Shape2 and so on as we did in VB 6.0 and earlier versions. Please correct me if I am wrong on that note.

I have VB 2008 as part of the Visual Studio 2008 package and using shapes is a totally different animal. This link provides a brief overview.


Eric one of the slickest examples I remember using VB 6 with shapes is a PID controller loop written by a fellow named Max Seim. That sample is still out there and can be downloaded here. If you have not seen that code sample give it a shot. Really good stuff. Unfortunately it won't convert to newer versions of VB. :(

Ron
 
Last edited:
hi Ron,
I still use VB5.
I am not sure about the recent versions, but I did look at the overview link, looks a much versatile way of doing the animation.

I ran the PID program, very nice demo. I will read thru the code later.

Many thanks for both those links.
 
HI Ian

I gave it a try in VB 2008 and it would not upgrade it. It tried and finally hung. I tried to open the .sln (solution) file it created and it was a disaster. I am not really surprised as some files created in VB 6 and earlier convert fine but it seems every time I try to work with a file that used shapes it becomes a disaster of errors. Maybe the OP will have better luck than I did?

Ron
 
I should really have a copy of VB 2010 but as I now use .NET a lot I need to keep my computer simple if I install VB as well.... well unintended things happen in Microsoft.

Ian

Hi Ian,
My sentiments exactly..:rolleyes:

My VB5 maybe 'olde worlde', but its like an old violin, I can still get a good tune out of it.

I don't fancy trying a Microsoft 'mix n match'.... maybe it will be OK, maybe not.!

Eric
 
I should really have a copy of VB 2010 but as I now use .NET a lot I need to keep my computer simple if I install VB as well.... well unintended things happen in Microsoft.

Ian

While I do have VB 6.0 I also have the newer versions. Well as to Visual Studio 2008 anyway. They all do seem to play well together. However, I am not a programmer type. I get the software for about free through the Microsoft HUP (Home User Program) through my company I work for. I just write basic data acquisition stuff in VB 6 for the most part. VB 6.0 does run OK on Vista 64 and Windows 7 but does need the VB 6 SP6 installed when VB 6 is installed. I have also used the Express versions free from Microsoft and with all installed, they do play well together on the same system. Overall though, my go to has always been VB 6 as I know better how to use it than the newer stuff. It just plain works for me and what I want to do. :)

Ron
 
Hi people,
can someone help on how to write a code on how to increase and decrease the time interval of the timer in the scroll bar procedure as stated on the attached file of this thread?
thanks.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top