Results 1 to 7 of 7

Thread: Constant required when use API ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Posts
    124

    Question

    How do we decide whether the constant is required when use any API ?

  2. #2
    Lively Member Surgeon's Avatar
    Join Date
    Oct 2000
    Posts
    121
    Generally, you can tell if you need any constant by looking at the documentation of that API function.
    Could you be more speciffic ? I mean what API function are you talking about ? Maybe I could find some help for ya...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Posts
    124
    I was looking at the example of the "GetFileTime" from one of the site, and the example did not shows we need to use the constant. Result of the example return a value 0. From the experience on the current project which I copied the code from one of the thread, it uses the constant and it works. I tried remark the constant, and I got the same "0" value.

    Curious about how to find out whether constant is required if I use the other API.

  4. #4
    Addicted Member matbrophy's Avatar
    Join Date
    Sep 1999
    Location
    Kent, United Kingdom
    Posts
    149
    Look in the API Text viewer.

  5. #5
    Guest
    A constant is simply making a large number more memoriable. For example, It's easier to remember Pi, then 3.142857...

  6. #6
    Guest
    Basically, it just makes something shorter. Say for example, you use the blue values:

    Code:
    'Form delcarations:
    
    Const blue = &HFF0000
    
    Private Sub Form_Load()
    Me.BackColor = blue
    End Sub
    Or, VB's own constant:

    Code:
    'Form delcarations:
    
    Const blue = vbBlue
    
    Private Sub Form_Load()
    Me.BackColor = blue
    End Sub
    Constants can make your programs self-documenting and easy to modify. Unlike variables, constants can't be inadvertently changed while your program is running.

    ..just makin' life easier for ya .

  7. #7
    Guest
    Originally posted by Matthew Gates
    Basically, it just makes something shorter
    Not really. I think the correct definition is that they make things more understandable.

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