C# - Declaring Hex Constant In .net?
Apr 20, 2012How can I convert the following code into VB.Net?
private const UInt32 temp = 0xE6359A60;
I tried the following but it doesn't work.
Public Const temp As System.UInt32 = 0xE6359A60
How can I convert the following code into VB.Net?
private const UInt32 temp = 0xE6359A60;
I tried the following but it doesn't work.
Public Const temp As System.UInt32 = 0xE6359A60
visual basic 2008 express
' the following lines declare the variables and constants
Dim intDiameter As Integer
Const dblPI As Double = 3.14159
Const dblAREA As Double = 140125
Dim intLabel As Integer
Private Sub PizaSliceCalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code]...
I made a working program to calculate piza slices, i was told i needed to declare pi and the areas as constants. when i rewrote the program it no longer works. the result keeps coming back as 0.
Having problem declaring constant on Visual Basic. rents is $200 per hour and is charge by minutes this is what I have so far.
const TOTAL_CHARGE_GROUP as Interger = 200 ©
How would I go about dynamically declaring a constant? (It's value is dynamic, not the variable name)
View 5 RepliesWhen building a class library which contains many classes, all classes uses a lot of common constants and functions, what is the best to do:
1- Declare these constants and functions as public in a module.
2- In each class declare constants and functions used by individual class as private.
The first choice is good for easy and fast implementation, but re-using a class in a different project will require importing the module to the other project.The second choice require a lot of copy/paste for code snippet but a class can be re-used in different project easily.
I am looping through all of the forms in my app, and I am needing to get a value from the form somehow.Example, say if I have the form named "This Form" and somewhere in that form, dont know if you can use the tag property for this or not, but I need to put a word like "Tall" for an external reference to the form.[code]"How do I get another value like the forms tag or something else".
View 5 RepliesExplain or send me in the right direction.
View 2 RepliesI have strMyColor = "Red".I would like to make lblMyLabel.BackColor to be red.Without using a variable the code would be this:
lblMyLabel.BackColor=Color.Red
I tried using the variable like this: lblMyLabel.backcolor="Color." & strMyColor
But the error is that a string can't be converted to System.Draw.Color. I understand that, as the string "Color.Red" is not the same as the VB constant Color.Red.Is there a way I can construct a valid vbConstant from a string?
I mean why? I mean to organize things I often turn modules into classes where all the methods are share.But then I thought, why not organize them into namespace?But then we can't declare constant in namespace.
View 10 Repliesi am making a program on visual basic 2010 and part of my objective is to calculate the tax, i am trying to calculate the TAX so this is part of my code and this is the only part which gives me errors:[code]
1. Constant cannot be target of an assignment
2. value of type 'string' cannot be converted to 'System.windows.forms.Lebel'.
I'm trying to make following subroutine work. The problem is this part of the statement.[code]I've tried everything and can't seem to come up with a constant to use here.[code]
View 3 RepliesI have created a program that creates a blank database in a users account (each user has a seperate folder when registered) by pressing a command button, i have got it to create the database but when i try to populate it with a table to go to the correct folder i get an error
Constant expression is required
the code im using for this is:
Const strConnection As String = ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
[code].....
where i can find out constant value used to control the windows. like i'm using wndproc to disable validation and i use constant value for closing of form and that value is &HF060&
i was also looking for constant value for leaving the form. is there any place where i can find out these values?
Alright, So i have two forms open. One in a listview and i have another window with a browser control in it. The browser is adding data to the listview but i made it so it hides while doing this using Me.Hide(). I can make it appear if i click the menu item "Show browser" i made.when im on Form1 (the listview) and its doing its thing with the browser window hidden. It keeps making form1 flash. Well not flash but like the browser window is poping to the front (while hidden) causing me not to be able to click on anything on Form1.This happen everytime the web browser navigates somewhere.Making Form1 always on top fixes it, but it also gets on top of other programs like my web browser . I want it to be on top only to the web browser.
View 1 RepliesWhat's the difference between enum and constant?Are they useful in real-life programming? or do they exist solely to make coding more tidy? Do they serve any real purpose?
View 1 RepliesI want to display a constant value in a text box. I have a constant of 2% calculated and the function works ok - as planned but i would like to display the tax rate of 2 % in the form at the time of calculation.[code]
View 5 RepliesI want to know that how we access a constant which is declared in a public structure, with an instance of that structure?
View 7 RepliesI need some of my initialization code to be blocked off if I am in Design Mode. This code is ran in the new method of the form, so it runs before the DesignTime Property can be set. Is there, or is there a way to setup, a compiler constant which indicates whether or not you are in Design Time. The Debug Constant doesn't work because when I run the application in Debug mode I want it to run
View 14 RepliesI currently have a table that has a few hidden text boxes... The text boxes become visible when certain actions are performed.
The table though changes size according to when the textboxes are visible or now. Ex. When the textboxes are visible the table grows, and vice versa.
I save a lot of settings in an INI file as 1 (enabled) and 0 (disabled), all around the project's module i have this check If setting = 1 then ' do somethingEnd If ' OR If setting = 0 then ' do somethingEnd If
My question, is it good for performance to declare public constants to hold 1 & 0 and use them in such above checks instead of using real number?
In general, if i use value like 8, 9, "", "$", etc... in just two different places, should i declare constant for it?
I have situation where I read a source file, create a temporary text file of the source and modify the temp file. If I open the file twice it appends to the end of the first temp file even though Ihave StreamWriter append set to false. Only if I close and reopen my application does it not append. It like there is buffer or something not getting cleared.Below is the syntax I'm using.
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Using objReader As New IO.StreamReader(OpenFileDialog1.FileName)
[code].....
Is there any way to put spaces in a C# enum constant? I've read that you can do it in VB by doing this:
Public Enum EnumWithSpaces
ConstantWithoutSpaces
[Constant With Spaces]
[Code]....
That implies to me that the CLR can handle an enum with spaces.
I would like to use a keyword (reserved word) as a constant name in an enumeration.The reason I care about the name is I set a ListBox.DataSource to the .GetValues of the Enum Type.This way the list of constant names show up in the list box and the ListBox.SelectedValue can be tested to determine which constant value has been selected.What I would like to be able to do is as follows:
Enum
Style
As
Byte
[code]....
This was an attempt to override the Name property from S to Single However I get a pre-compile error stating: "Too many arguments to 'Public Sub New()'."
I am getting these constant annoying errors in Visual Basic .NET 2010 Express. I'm pretty sure I'm not the only one, but these errors are always relating to images and resources The Type 'Global.ExampleProject.My.Resources.Resources' has no property named 'example.png'I am pretty sure these are bug, due to the fact that I get these errors after a while in most of my projects - it's absolutely annoying! Most solutions include removing the resources (commenting them out of the form designer code) and re-importing them... But then the problem comes back again after the project has been loaded a few times!
Microsoft suggest this is rather a user-related issue rather than a bug due to the fact that they can't reproduce the error.I'm still sticking to the belief of this being a bug - anyone get this error alot of the time?This is not the only bug I get - sometimes VB stops working when I try to build my projects!
Is there a way to assign a color.fromargb value to a constant?
View 3 RepliesAny way to assign a binary value to a vb variable? All of the obvious choices don't work. I've tried prefixing with &B, appending with b but nothing seems to work.For clarification, what I was looking for (which does not appear to be possible) was how to assign a literal binary number to a variable, in a similar manner in which you can assign a hex or octal number. I was just looking for a more visually engaging way to assign values to a flag enum.
Dim num as Integer = &H100ABC 'Hex'
Dim num2 as Integer = &O123765 'Octal'
Dim myFantasy as Integer = &B1000 'What I would like to be able to do'
Dim myReality as Integer = 2 ^ 3 'What I ended up doing'
Is there a way I can assign a value to a class attribute using a constant? would like to do this so that I don't have tocode a constant value in the attribute and then again inside the class.
<TemplatePart(Name:=TESTVALUE, Type:=(GetType(ContentControl))>_
Public Class MyContentControl
Inherits ContentControl
[code].....
I need to know the IOCTL constants for the various strings (for example the value of the constant of IOCTL_ATA_PASS_THROUGH). Searching the net I found that those constants are defined in the header Ntddscsi.h but those constant are wrong. For example the constant value of IOCTL_ATA_PASS_THROUGH should be 4D02C while in the header file it is 40B
The question is: where can I find a list with ALL the right values?
I've found [URL].. where there are listed all the codes. the value in Ntddscsi.h is not the "final" value
I have a project in VB.NET 2010 (compiling to x86, .NET 2.0 runtime) that I want to compile into two separate EXEs - a "lite" version and a "full" version. Unfortunately I cannot make two separate projects as it uses the Adobe Reader COM control - and sharing a form using that control between two projects seems to confuse the IDE (something to do with COM Interop, I assume - if someone knows how to share a form hosting the adobe reader control, that would solve my problem too).
I have found this thread: C#: VS.NET: Change name of exe depending on conditional compilation symbol however I don't have any MSBuild experience so I need more explicit instructions. On the "My Project>Compile" tab there is a "Build Events..." button. I was wondering if anyone knows how to set a conditional compilation constant and use that to determine the EXE name (or change it after build). If all else fails I can rename the EXE manually I suppose, but I'd prefer it to be automated.
Using the code from this thread, I have been able to successfully register hotkeys for myself. I am having trouble though, I am trying to register a hotkey with the Control Constant; it doesn't seem to be working. I need to register Control + 1 (MOD_CTRL, Keys.D1). I know how to do this, yet I can't seem to get the MOD_CTRL constant to work. I've found that the constant for Control is &H11 but as I said previously, this does not seem to fire for either the left control or right control keys.
[Code]...