Solved

Newbies questions part1.

Posted on 2004-04-01
4
186 Views
Last Modified: 2010-05-02
Hi Expert,

Q1: Why some people places a "exit sub" when there's no error management... is it faster?
ex.: private sub BilyBob()
           <instructions>
           exit sub <----
      end sub

Q2: what means "&Hxx"
ex.: Const KEY_SET_VALUE = &H2 or Const SWP_HIDEWINDOW = &H80 or Const TOTO = &0, etc.

Q3:...
Dim lTest as Long
lTest& = Clng(number)  -> why the "&" after the variable?

thks for all...

Mart

0
Comment
Question by:m_renaud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 125 total points
ID: 10732170
Hi m_renaud,

The protocol of this site is against asking multiple questions within a single thread so you are better off asking seperate questions in future.

1) Doesn't have to be based on error management, you may want to exit a sub or function earlier in your code based on some condition or other. For instance if a certain variable holds a certain value you may want to exit the sub rather than carry on processing. Of course this can almost always be handled by restructuring the code!

2) &Hnn means it is a hexadecimal number for example &Hff is the number represented by FF in hexadecimal, namely 255

3) & at the end of a variable explicitly defines it as a long integer, variable$ would be a string, variable% an integer and there are others. This is partly a backwards compatibility issue and also partly because it is useful at times to explicitly type a variable or value in an api call.

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 13

Expert Comment

by:crazyman
ID: 10732171
1) no it is no faster and some people will argue it is bad practise

2)&Hxx is a xex value

3)lTest& is a shortcut way of saying the variable is a long like
dim l& would be typed as long
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10732182
Q1 - Exit sub

Could be several things.  
Personal preference, habit, or the way they were trained
Error handling code has been removed
Coding standard

Q2 - &Hxx
VB - & declares the value as a LONG
C - &H - Hex number

Q3 - & after
VB - Declares it as a long.

mlmcc
0
 
LVL 3

Author Comment

by:m_renaud
ID: 10732234
Hi TimCottee,

it was 3 littles questions... i did not believe them enough important to make three questions...
next time i'll pay attention...

thks for answers

Mart.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question