Solved

how to declare variable in vb

Posted on 2001-06-12
10
215 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
  • 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
 
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 50 total points
ID: 6180672
public const VNET_CFLG = &H100

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now