Visual Basic and graphics - for the novice/beginner

Hi there

I have no training in programming, but would like to start writing my own little programmes. In my work (civil engineer), I am increasingly frustrated by the lack of simple, time saving programmes to make my life easier, and hence the urge to write my own programmes. Of course, the start will be no more than programmes for one-off formulas, but having said that, I would like to (in many year's time) be able to write more complicated programmes. And of course what I have in mind involves graphics, specifically being able to draw (for instance) pipelines (with coordinates) and then be able to generate a longitudinal section from that and superimposing waves (that moves in real time) on the longitudinal sections.

My question therefore is:"Would visual basic allow for enough flexibility/power/etc to do what I've got in mind, or would another programming language suite my application better". I realise that programming is not for the faint hearted, and I would like to start off on the right track!

Can someone advise please.

Thanks

Astericks

PS - I hope my rambling above makes sense!



Answer this question

Visual Basic and graphics - for the novice/beginner

  • bataras

    An excellent book on this sort of thing is 'Code Complete'. To answer the question - putting them at the start puts them in scope for the whole function, which can make debugging harder ( although you should also keep functions short, that's another CC tip )

    C * requires* variables at the top, I suspect that's where the approach comes from.



  • dkocur2

    VB.NET will do all of this, as the .NET framework provides good graphics support. The library is called GDI+, and once you learn some core VB, a good GDI+ book will give you all the info you need.



  • Charlemagne

    Well, Astericks, I guess the resolution is this.

    If I were you, I'd listen to Cgraus. He's a damn good coder. There is a little bit more theory behind understanding his methods, but they are good, solid methods that will stay relevant for you.

    The methods that I mentioned have alot less theory behind them and might be easier to understand coz you're just starting out, but they aren't very practical once you start doing the proper stuff.

    It's your call, but either way I'm sure I can speak for Cgraus when I say him or I would be glad to help where we can.



  • deeptranz03

    I Agree whoelheartedly that VB is an excellent choice of language.

    You can start out with VB Express which is free to download and is full featured and exactley the same language as the pay versions. Some of the advanced IDE features are disabled but for most purposes this would not cause a problem.

    If you want to do graphing functions then VB is designed in such a way that you can easily use 3rd party graphing components into you applications to save you having to write them yourself. There are many of them available - some free some you can to purchase.

    Either way there are a huge amount of resources to help you along the way. But the environment for developing windows applications is extremely simply to get going with and you'll be creating applications very quickly.

    I'd definately download VB Express and try it out.

    http://msdn.microsoft.com/vstudio/express/vb/


  • ZeyadRajabi

    Hehe, you know what the funny thing is, Cgraus I don't use CreateGraphics OR the paint event handler hahahaha

    I guess everyone has their own set of methods and styles that they use. Their own steps for development. If we weren't different, all programs would look the same! And then where would we be

    Using apple's thats where.

    *shivers*



  • icelock

    Really I didn't know about CreateGraphics until you mentioned it. What other method do you use



  • banchuan

    OK, I guess we just disagree then. If there was a ream of code involved in adding a paint handler, I'd perhaps agree. However, it takes but a moment, and builds good habits. I 've met a ton of C++ programmers who were taught by a professor who knew C, and they have formed habits they find hard to break, such as declaring all variables at the start of a function, or using FILE handles for file IO, because that's what they were taught, any other approach is interesting, but what they learned first sticks with them.



  • CARABAS

    Even though it's not a practical, nor good way of doing things, the "CreateGraphics" method will be your best friend when you're first learning GDI. It will at least get you started with some very easy to use and simple things.

    GDI is one of my better points for VB.NET. If you would like any specific help, feel free to email me at alex.norton@unitab.com.au and I'll do what I can to help out :-)



  • nhlpens66

    Aye, been awhile since I looked at that title. I had it somewhere and when I just looked for it it seems it's gone. Anyways thanks for the tip. If you ever see me on the forums saying something and you know a better way let me know with a reply.

  • Trev

    I'm still at a loss over this. Handling the paint method instead of misusing CreateGraphics and learning bad habits is actually quite trivial.

    To do any sort of drawing, you should add a paint event handler ( which means go to the form properties, click the lightning bolt, go down to 'paint' and type a method name ( typically OnPaint ) ). Then you get a method that draws your form, where you can put any drawing code you like. You can change the drawing at any time, just change code that will change how OnPaint draws ( such as adding points to an array that's drawn as a line ), and call Invalidate()

    GDI+ is pretty awesome, I have to say. I was nearly done writing a paint program in GDI when it first appeared in the PSDK, and a lot of stuff I'd worked hard on suddenly became trivial.



  • Galex Yen

    I learned to declare variables at the first of the function. But, I tought myself all I know. So, what do I know Anyways, what is wrong with variables at the first of the function Should they be declared as they are used



  • Richard III

    I agree with Christian or atleast override the on paint of a panel or something. Never use CreateGraphics unless you are painting on a bitmap, something in memory, or it is the last resort.

  • Jon Asbury

    I concur, I am always happy to help out, even if people decide not to do things the way I suggest.

    As far as I can see, the CreateGraphics method is useful, for creating stuff you WANT to see erased, such as a rubber band. You can draw it, call invalidate, and it will just plain disappear :-)



  • Laiko

    I agree with your method as being better, cgraus, but I also believe that getting a strong understanding of things like co-ordinate positioning, colour values and all the basics are just as important. CreateGraphics is a piece of c**p when it comes to doing anything actually practical as it doesn't refresh and doesn't make use of embedded graphics. I know all this, and I'm not saying that it's the way to go in the long run, but when someone is first starting out it gives them a very simple, easy to understand alley to develop a more thorough understanding of how graphics works. After all, how will someone learn why CreateGraphics is the wrong way to go if they've never discovered its limitations. When people are first learning to do graphics work in VB.NET, I always suggest CreateGraphics simply because it is INCREDIBLY simple and it won't take long before they DO realise it's harsh restrictions on what can be done. But, then, as they move on and find better ways of doing it such as your paint event handler, they will have a better understanding of WHY they are doing it, rather than just copying and pasting like script kiddies.

    After all, I believe it was Carmack who once said "Anyone can learn to program, but no-one can learn to be a programmer."



  • Visual Basic and graphics - for the novice/beginner