Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to declare variable in vb

Posted on 2001-06-12
10
Medium Priority
?
223 Views
Last Modified: 2010-05-02
the following statement written in c header file:

#define VNET_CFLG 0x00000100

how to write the above definition in vb module.
I try write like this:

public const VNET_CFLG = 0x00000100

but error. vb doesn't reconize 0x00000100
0
Comment
Question by:azsoft
[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
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6180349
You should declare it as &H100

The &H identifies the following characters as a hexadecimal number (effectively what the 0x prefix does in C).
0
 
LVL 3

Expert Comment

by:sombell
ID: 6180369
Also see my response to your other question about C header files.

Sombell
0
 
LVL 2

Expert Comment

by:dwalsarie
ID: 6180420
C:
#define VNET_CFLG 0x00000100

Visual Basic:
Public Const VNET_CFLG = &H00000100

where 0x identifies hexadecimal in C, &h does the same for VB
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Expert Comment

by:WalterM
ID: 6180453
I would recommend adding an ampersand (&), as in

Public Const VNET_CFLG = &H00000100&

This will ensure that the constant value is interpreted as a 32-bit Long value, which is especially important when the value is negative; interpreted as a 16-bit Integer, a negative value will have a different binary representation and may lead to incorrect results when used for calling an API function.

Michel
0
 

Accepted Solution

by:
Koothan earned 150 total points
ID: 6180672
public const VNET_CFLG = &H100

0
 
LVL 3

Expert Comment

by:sombell
ID: 6180693
Koothan,
please read the guidance for experts. It's generally not "done" to dive in a propose an answer.... especially when several others have already said what you proposed.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6180767
Well said sombell, though Koothan is brand new on the site today so can be forgiven this once! (But not more than that). There are guidelines at the bottom of this page on comments vs answers, please read them and follow this guidance in future. If you continue to post "answers" instead of comments especially when you are duplicating the responses of many other experts your account will be referred to customer services for possible penalty such as suspension of your account.

azsoft, you should reject this proposed answer and select the first comment that gave you the answer. All of the posts as far as I can see have given you exactly the same (correct response).
0
 
LVL 15

Expert Comment

by:ameba
ID: 6181371
or maybe:
Const VNET_CFLG As Long = 256    ' :-)

Small tip: "Use the right type for constants" http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=11
0
 
LVL 15

Expert Comment

by:ameba
ID: 6182132
My comment was just a comment - you are NOT allowed to accept it as answer!!!
0
 
LVL 15

Expert Comment

by:ameba
ID: 6182144
It should be forbiden to drink and accept answers at the same time!
0

Featured Post

Independent Software Vendors: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 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