Coding Assistance

UltimaGeckoUltimaGecko hates endnotes Join Date: 2003-05-14 Member: 16320Members
<div class="IPBDescription">...for VB though</div> I'm working on a psuedo-game type thing, due to my limit knowledge of programming in C++ in anything but the console (and lacking a C++ compiler that I know how to use), I'm programming it in Visual Basic 6.0.

Which leads me to one of the parts of Visual Basic I have almost no knowledge of: classes. I know there's a class making wizard, but that doesn't help me much. So I'm wondering if anyone would like to share the secret of a few VB programming things with me:


1. How can I get pictures from a file to display in an image/picturebox (I've found having all the images on the form, just .visible = False, works okay...but I think it would be more beneficial to have all the images able to be edited outside the program.

2. Some step by step tutorials for programming classes in Visual Basic, only because of the fact that you can't nest user made type arrays...and I really need some nested type like structures...and classes seem to be the closest thing (and from my limited knowledge, I could make all the variables public to access them in the same way, and still make an array out of it).

3. If all else fails: lots of tutorials of how to make graphical user interfaces for C++, and you know...basically any C++ tutorials you'd want to throw my way. Since Visual Basic seems a bit unsupported in the tutorials department.


I even tried that Microsoft database of examples and definitions, but that didn't help much...since VB.net seems to be the new big thing and VB6.0 is virtually forgotten, though they're nearly the same...I'm not sure if classes would work the same, and I don't use .net.


So, any help in any of those departments?

Comments

  • CodemanCodeman Join Date: 2002-11-21 Member: 9497Members, Constellation, Reinforced - Shadow
    I haven't done VB for a long time (not since uni 2 years ago) so I can't help on the classes thing, but I'm sure I remember using a "LoadPicture" function or something similar to load pictures at runtime...

    Here I checked MSDN for you: <a href='http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbfctloadpicture.asp' target='_blank'>http://msdn.microsoft.com/library/default....loadpicture.asp</a>

    Online MSDN is your friend when coding the microsoft way >_<

    If you feel VB isn't powerful enough but you want the convenience of designing UI's still, I recommend you take a look at Borland's Delphi - it uses the Pascal language which is easy to learn coming from a VB background (I did this like 5-6 years ago) and it can do almost everything C++ can. There's a lot of tutorials and stuff around for it too (even OpenGL if you're into that sort of thing).

    Hope that helps...
  • DOOManiacDOOManiac Worst. Critic. Ever. Join Date: 2002-04-17 Member: 462Members, NS1 Playtester
    Are you doing VB6 or VB.net, cause the two are completely different when it comes to classes.

    VB.net is a fully OOP (Object Oriented Programming) language, where as in VB6 classes are thrown in kind of as an afterthought..


    Anyway, the general concept of classes can be discussed regardless of the language, so i'll give you a few bits to get you started:


    I assume you've done structure data types, where you can stick multiple values in 1 variable, like having a "person" variable, and you can have person.name (a string), person.age (integer), etc. Classes are just an extension of this concept, they are structures with functions too. i.e. person.goDoSomething().


    I forget the VB syntax, so here's an example in C++ style pseudocode. Its pretty easy and is just meant to give you the basic idea:

    <!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->structure person
    {
      Integer age;
      String name;
    }
    // This is a structure, like I was talking about. It can be used like this:
    student = new person;
    student.name = "UltimaGecko";
    student.age = 20;


    // Now here is a CLASS, which is the same as the above, except that it has functions too!
    class person
    {
      Integer age;
      String name;
      Function Boolean sucksAtInternet(); // function that returns true/false
    }

    // You can do the following...
    student = new person;
    student.name = "UltimaGecko";
    student.age = 20;

    if (student.sucksAtInternet())
      print "haha, you suck.";<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->

    Again, that was all pseudocode and by no means valid syntax for, well, anything. Its just to show you the idea.
  • SwiftspearSwiftspear Custim tital Join Date: 2003-10-29 Member: 22097Members
    I hated VB... although it was the only code engine I ever built a working game in (at least a working game that wasn't a computer assignment)
  • UltimaGeckoUltimaGecko hates endnotes Join Date: 2003-05-14 Member: 16320Members
    Yea, I only have VB6.0. So I would need classes in that, I think they're sort of defined like types...but then there's something about Let, Get, Set and using the functions and a bunch of other stuff I don't remember.



    Specifically, I need two nested types, from my program:

    SolarSystem(0,0).Planet(0).Name (or whatever) - except VB doesn't let you nest a second type, that is: .planet(0) would be invalid, you can't have an array there...which is really annoying.

    In VB classes are nested all the time (and it makes me wonder why they just didn't let Types be nested).


    So I've got the
    <!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Type SolarSystem(iSSMinX to iSSMaxX, iSSMinY to iSSMaxY) as Star
      Type Planet(iSSPlanets) as Bodies 'no nested types...
          Public Name as String              
          Public Radius as Single
      End Type
     
     Public Temperature as Single
    End Type<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->


    So I would just make the planet type into a class, and have that nested instead (which would, as helpful as it is, allow me to calculate density and stuff as part of the class instead of functions...except I don't know the syntax for classes).


    This is what happens when you don't take a programming class in 4 years (although, in reality, I know more about VB now then I did in class).


    Thanks for the LoadPicture thing, that should probably work.
  • TyrainTyrain Join Date: 2003-01-03 Member: 11746Members
    Just as an info: If you want to learn C-based language try C#. It's compiler is Microsoft Visual Studio.Net 2003. As far as I can tell it's much easier than all the other compiler though it's a mircosoft one.
  • UltimaGeckoUltimaGecko hates endnotes Join Date: 2003-05-14 Member: 16320Members
    I have sort of found a solution, but it really drags off on the grammar at the end (like someone spell checked it for the first few pages and then BAM the person sounds like a non-English speaker (with frequent verb tense and subject mistakes), <a href='http://www.developerfusion.com/show/3959/' target='_blank'>here</a>.

    I'd appreciate an indepth tutorial on classes in VB6.0, still. Most importantly Let, Get and Set and the the Property keywords (as useful as the above tutorial may be, it starts dropping off just before/during the part I need, and while I could make a class with all public variables, I'd rather not, incase I want to edit it after I'm done).

    Why do they have to call them classes? It just makes it so much harder to google, pfffft.
Sign In or Register to comment.