Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

how to declare variable in vb

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
azsoft
Asked:
azsoft
  • 3
  • 2
  • 2
  • +3
1 Solution
 
TimCotteeCommented:
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
 
sombellCommented:
Also see my response to your other question about C header files.

Sombell
0
 
dwalsarieCommented:
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
WalterMCommented:
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
 
KoothanCommented:
public const VNET_CFLG = &H100

0
 
sombellCommented:
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
 
TimCotteeCommented:
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
 
amebaCommented:
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
 
amebaCommented:
My comment was just a comment - you are NOT allowed to accept it as answer!!!
0
 
amebaCommented:
It should be forbiden to drink and accept answers at the same time!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now