Solved

how to declare variable in vb

Posted on 2001-06-12
10
220 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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
 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

690 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