Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

VB6 And &&H Constants...

Can anyone explain what the difference between the following statements is:

Dim lValue As Long

lValue = 65536 And &HFF00
lValue = 65536 And &HFF00&

For the first statement, lValue = 65536
For the second statement, lValue = 0

If I do the following:

lValue = 65536 And &HFF0000

VB works correctly (lValue=1) and it won't let me add the extra & on the end.

Why do I need the extra & on the end on Hex numbers that end in 0?


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
API Constants List (all The &&H... Constants)
Hi to all..

I've been using API's for a while and I asked myself...

Why there are all those constants such as

Public Const GWL_WNDPROC = -4
Public Const WM_NULL = &H0

end very very very much more??

so I would know if anyone of you has a complete list of those constants..

I'm not asking the explanation for every constant this would be a hard mission.. but only the list with the values...


Key Constants
Can anyone tell me what keys the following VB constants stand for? I have never seen any of these on a keyboard?

Constant Value Description
vbKeyCancel 3 CANCEL key
vbKeyClear 12 CLEAR key
vbKeyExecute 43 EXECUTE key
vbKeySnapshot 44 SNAPSHOT key

Any help would be greatly appreciated...Thank you!!!

Ok, I am a newbie with visual basic and i have one question. what are constants? or i know what they are but,

Public Const HWND_TOPMOST = -1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_NOTOPMOST = -2

I dont know where comes these numbers: &H2, &H1, -2, -1, &H1A9

so can someone explain me what are those?

Hex Constants
I am running into a strange problem with hex constants, here is some example code:

dim x as long

x=49333 ' I would not normally use decimal, but you see why I did it this way

select case x
case &hC0B5
' do something
case else:
' do something else
end select

It always takes the else path because &hC0B5 seems to evaluate to -16203. I want to throw something. You would think VB would be smart enough to evalute in the context of x (long)..... Can I force it to do that?


Is it possible to make an array of constants of a certain type and keep this all enclosed in a module?

Constants And Their Uses?
Owch, may have realised that I have a lot of problems with Visual Basic by now, I thought I'd split the problems up so that if anyone has an idea about one thing but not another then it's easier for them. Sorry if that logic is skewed.

Anyway, constants are the problem here, so far I have got two sets :

'Window arrangement constants

Const vbCascade = 0
Const vbTileHorizontal = 1
Const vbTileVertical = 2
Const vbArrangeIcons = 3

'Cut/Copy Paste constants
Const COPY_TEXT = 0
Const CUT_TEXT = 1
Const PASTE_TEXT = 2

I need to use them under one menu (so for the window arrangements its mnuWindow_Action

How do I get it to arrange the windows by using those numbers?

Cheers again

API Constants
Does anyone know where I could find a list of API constants? I'm trying to re-write some C++ code in VB and don't know the constants to some of the API calls. For example I don't know the value of the CREATE_ALWAYS constant in the API call:


I use the site a lot (its very good) but they don't have all the constants listed. I looked around the MS site but couldn't find anything.

Any suggestions?

Hi can anybody help please?

To make life easier, I am creating a small application which will basically tell me the structure of databases in SQL Server. When I read the values of the column type it brings them back as Long numbers. I know which constants represent which numbers i.e. adChar = 129 etc.

My question is, in order to display adChar instead of 129 would I have to declare a constant for each possible number or would it be better to pass the number to a Select Case function. OR is there any function to convert a number to its VB Constant (probably not but it would be handy to have).


I am trying to figure out if using Constants is faster than using Variables. If I have 50 different values to maintain. I can do it with 50 constants or two variables and modify the variables each time. I am wondering which is more efficient. Any Ideas anyone?


Dll Constants
Hello. I need a dll with public string constants. I want to add this dll as a refence to a vba project and a web service one. Can anyone help me? Thanks in advence.

Constants In Hex@#$% Help!
Hi Folks,
I need to set up a list of constants that will offer a hexidecimal conversion. Example. Chr$(2). I keep getting an error when I enter the following: Const STX As String = Chr$(2)

Could anyone please help before my brain melts?

Thanks in advance,

Using Constants
I have an application with over a dozen different forms. There are several items of information that are established in the original splash screen that I want to carry into all of the forms.

As an example, the user's ID. I have tried the several alternatives in the Help system to no avail.

Using the following code produces an error message:
Public Const strID =txtID.Text

Using the following code only retains the constant in the splash form that it was originally entered in:
Const strID =txtID.Text

Is ther a way to retain this type of information throughout multiple forms and procedures in the same application?

Edit: Moved from Database

A Few Constants I Need...
I need the values for these constants, and there not in the api viewer that comes with visual studio, and ive been looking on google and ive been finding like 3 different values for each one. I was wondering if anyone here knew 100% that they were right?



API Constants
Where can I find the value to the API constant BELOW_NORMAL_PRIORITY_CLASS used in the API call SetPriorityClass?

Any suggestions?


what intrisic constant will seperate a message into multiple lines??

Where Can We Get API Constants?
I am using API Guide 3.7 to get the syntax and examples when programming with APIs, but there is one thing missing in the documentation: the value of constants.

For example, with the BITBLT function, there are dozens of values for the operation (WHITENESS, BLACKNESS, DSTINVERT, etc) but the numeric value of those constants are not documented.

Is there a central place where we can obtain API constants?

Help On Api Constants
THE Api viewer doesnt have the BM_DISABLED constant could someone please help me with that?

Three Constants
I'm almost kicking myself for asking this. It's been at least 3 years since the last time I used anything like this in my code. I totally forgot how to use them or if this was the purpose for them.

These are the AND, OR, etc operators.

I have the constants, COMMENTA, COMMENTB, and COMMENTC.

VB Code:
Dim sChar As StringsChar  = txt.Text If sChar = COMMENTA Or COMMENTB Or COMMENTC Then ' error in this line'stuff happens hereEnd If

It keeps giving me a type mismatch error. What could be wrong?
Also all the constants are strings.

What Are Constants
Please favour me in the following.

1. What are Constants ?
2. What are the uses of Constants ?
3. How can we use Constants ?
4. Where from i can get the complete list of Constants ?

Please help me giving the answer

RAS Constants
are there ne ras constants which notify the data recieving n sending events ?.
also tell me that are there ne alternate for checking that after connection to internet are there ne methods / constants to get notified of data incomin n outgoin events.

API Constants?
Anyone know a place on the web to get the constants for most API functions?



API Constants
The API guide is a great tool.. but a lot of the functions in there show that they can accept a number of different values to return different results.. for example

setwindowlong as a number of parameters that can be used in it.. but the API guide only tells you what the constants for the params should be.. it dopesn't tell you what values to assign to them.. only the ones it actually uses in the example.. is there any documentation for the API functions that tell you what values to assign to these constants?

API Constants
Hi, I wonder how off does MS add new constants for API, is there any place I can get a up to date API Constants list?

API's Constants
hi all,

how do i get the constants which are not availavle in API viewer. i've extracted the constant from header files but sometimes it looks like

#define TVE_EXPAND 0x2000

How do i get its hexa or decimal value.

is there any place where all the constants are listed.


VB Constants
What are the other Control Constants in VB aside from the following:


Is there VB.DataCombo? What is the constant for DataCombo?

I've got a problem here, I'm creating a program to edit resource files. But MSDN describes a whole lot of constants, but half of them aren't in the API Viewer. I need them a lot and it isn't the first time I miss a lot of constants and/or functions in the API Viewer. Does anyone know were I can find them all?

Ok...I've been through lots of API functions and as you all know, many need all these constants like "&H40", etc. Well, I want to know where I can get a list of constants that I can use with the API functions.

Help With API Constants
In this code what is the &H1 and &H2 assign(what are their values)?

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Const SND_ASYNC = &H1

Also why use the & operator for

Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long

ret& = waveOutGetNumDevs

Are constants translated at run-time or compile-time?
(meaning, does the compiler actually replace each instance of my constant with the value, or is it treated like a variable?)

Since noone can figure out my other posts, how about this.
How do i apply more than one constant to a label mesage?
I.E Job Code 1
Job Code 2
Job Code 3
i can get the first one to work by using cons conmsg as String = "Job Code 1:"

WM_ Constants
I am looking for a reference that lists all of the WM_ constants and the values corresponding with them. I seem to have trouble finding these values when I need them. Does vb already have them declared, or do I have to know them ahead of time?

Constants In .exe
I defined my connection string:
objConn = "connection string id and pw, etc"

and then created an .exe
When I open the .exe in NotePad I can see the connecting string; other than constants, everything else looks all garbled up which is good.

How can I get the connecting string constant to look garbled up so that it can be hidden when I distribute the .exe.?

( email@removed )

This may sound like a stupid question, and maybe I'm just not thinking
correctly, but what exactly does it mean when a constant is assigned a
value such as "&H8"
Example: Private Const API_VALUE = &H8

What does the "&" symbol mean and what is the "H8"?? How many of these
combinations are there available and what exactly do they do??

Vb Constants
There are many constants in Visual Basic like vbCrLf, vbYes, vbRed etc. Is there somewhere I can go to get a complete list?


Edited by - wb6qdi on 2/8/2005 6:11:27 AM

VB6 And &&H Constants...
Can anyone explain what the difference between the following statements is:

Dim lValue As Long

lValue = 65536 And &HFF00
lValue = 65536 And &HFF00&

For the first statement, lValue = 65536
For the second statement, lValue = 0

Why do I need the extra & on the end on Hex numbers that end in 0?


Using API-constants

When using APIs you often need to pass some constants into the APIs.

How do you know what value they have? Or is there another possibility to use them as to declare each constant by myself?

For example: If you want to use GetLocaleInfo, there are the constants


What do you pass into your function in your VB-code?


Guys, who knows the answer to this question:
if a constant is declared in vb project, and NOT used, is the space allocated by vb anyway or not?

Button Constants

I wish that one button change his colour forever (colours: red and green).
I tried to create a subroutine but doesn't work!
The button must have graphical style!
Function Blink(but As button) As Boolean
but.Style = tbrDefault
but.Caption = "Test"
End Function

But I haven't any method BackColor which allow me to change button background!
How can I alternate red and green colour onto a graphical button?
The effect must be permanently!
Please, can anyone help me?
Thank you in advance!

How Can I Read VB Constants?
Is there a collection of constants I can access in VB5 that will tell me the height/width of common elements in VB like: 1) the height of a menu bar, 2) the width of a scrollbar, 3) the height of a title bar (the part that contains the caption) on a form???

Hex Constants For MSComm #@%*Help!
Hi Folks,
I need to set up a list of constants that will offer a hexidecimal conversion. Example. Chr$(2). I keep getting an error when I enter the following: Const STX As String = Chr$(2)

Could anyone please help before my brain melts?

Thanks in advance,

FmShiftMask Constants
Just out of curiosity...


Originally Posted by VB Help for e.g. MouseMove event

You can identify individual keyboard modifiers by using the following constants:

Constant Value Description
fmShiftMask 1 Mask to detect SHIFT.
fmCtrlMask 2 Mask to detect CTRL.
fmAltMask 4 Mask to detect ALT.

Those constants don't seem to be exist in "my" VBA (Excel 2002/10/XP) - no matches in the object browser, "variable not defined" when used in code. Could people verify that in other copies and versions?


Constants, And How To Find Them Out
How can I find out the values for non VB constants such as VK_A and SW_HIDE and MOD_SHIFT? Is there an Add-In or a download such as an API Viewer?

I have Googled far and wide in search of such a program, but none came up.

Constants Issue

i have placed around 1000 Constans in a notepad file.
i.e. Public Const WM_CLOSE = &H10

there are situations i just want load a constant dynamically in to the project from this notepad file.

how do i do that?


Get List Of Constants
Hello i have a problem with vbs scripts there is a constant &h5& for my documents where can i find a full list for the constants

Constants Being Public?
Hi there,

I'm making a program with several class modules. I have some constants that I want to use in functions in several of the modules. How can I do it so that I only write the constant once? It won't allow me to make the constant public.


Quick Help On Constants
I has wondering if somebody can help me. My brain was fried over the weekend and I was wondering if some one could help. I know this should be easy but I can't seem to get it. It C++ I have these:
#define _OSD_BASE0x9000
#define _OSD_YEAR4 _OSD_BASE+0
#define _OSD_YEAR2_OSD_BASE+1
#define _OSD_MONTH3_OSD_BASE+2
#define _OSD_MONTH2_OSD_BASE+3
#define _OSD_DAY_OSD_BASE+4
#define _OSD_WEEK3_OSD_BASE+5

My question is how do I do these in VB?
Public Constant OSD_BASE = ????? .....

Thanks for the help!

VB Keeps Rounding My Constants Down!
I've set a number of constants -

Const HUGE = 2
Const ENORMOUS = 2.5
Const BLUE = 2
Const CHEESE = 2.5

Then I need to add these figures up in a label, like so:

frmFinished.lblTotal.Caption = FormatCurrency(TotalPrice)

However, the ENORMOUS and CHEESE constants always display as "2.00" instead of "2.50". Does anyone know why it keeps rounding my figures down?

Constants And References
Is there some way to set up a reference so that it always referes to one of several different possibilities.
Example 1:
I have two possible reference to a single type of item. The reference depends on to where it was refered to from... long story. The two possissiblities are AD, ADS. Is there some way I can say that both of those have a single referent, say Advant, so that whenever I refer to Advant, both of those possibilities are caught. So that this would work:
Select Case Muse
Case Advant 'This would actually catch cases "AD" or "ADS"

Example 2:
In another case there are three possible referents to a single type of itme. The three references are DI, DISADS, DIS. Is there some way I can set up a pointer that would include all three of those instances as a single referent, say DI. So that this would work:
Select Case Muse
Case Advant 'This would actually catch cases "AD" or "ADS"
'Do This
Case DI 'This would actually catch cases "DI", "DIS", "DISADS"

Keycode Constants
Anyone know where I can find a COMPLETE list of all keycode constants? The list in VB Help is a good reference but it does not have all of the keys.


Copyright 2005-08, All rights reserved