Solved

how to declare variable in vb

Posted on 2001-06-12
10
217 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

785 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