Results 1 to 6 of 6

Thread: [RESOLVED] some questions

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Resolved [RESOLVED] some questions

    i'm using visual basic 6 and i have some questions that i need some help:
    -why, when, we use class variables or same objects variables we must use NEW(for declare) and SET(for change the value), but in normal variables we don't need use these keywords?
    -draw an image is the same: design an image?
    -what is the meaning of DOEVENTS keyword?
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: some questions

    1. In VB6 not every type is an object so those that are not don't need to be instantiated and object variable must be - therefore using the New keyword in most cases is a must.

    2. Image file and image property of the Form or Picturebox objects are not the same:
    Form.Print, Form.PaintPicture, Form.Line metods will create an image on the form (same goes for Picturebox).

    3. DoEvents is normally used inside loops - it passes control to operating system so your program is not locked and will allow to execute other events.
    It however comes with the price - DoEvents is cpu hungry.

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: some questions

    "1. In VB6 not every type is an object so those that are not don't need to be instantiated and object variable must be - therefore using the New keyword in most cases is a must."

    i'm sorry, i'm protuguese, but these hansher(is right write?) is confuse to me.
    why using in some cases NEW and SET keywords?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: some questions

    The easiest thing to say about New and Set is "that's the way VB works", but let me try to say what Rhino said in a different way.

    In VB6 you have variables and objects. When you use an object it is required that you bring a new one (a new instance) into existence before it can be used. This is called instantiating the object and you use the New keyword to do that. And as for using Set, well, that's just the way it is.

    BTW it's "answer" rather than "hanser".

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: some questions

    The alternative to Set is Let, but you don't actually need to write it (and most people don't), eg:
    Code:
    Dim x as Integer
    
    Let x = 1    'these two lines do the same thing
    x = 1
    Both Set and Let say to assign a value to the variable. There are two different words, as the way an object is stored is different to the way normal values are stored (so the work needed is different).


    You use the New keyword to create an instance of a class, rather than connecting to an instance that already exists.

  6. #6

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: some questions

    thanks to everyone. thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width