Assigning Binary Constant To Variable?

Mar 18, 2009

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

View 5 Replies


ADVERTISEMENT

Assigning Class Attribute Value Using A Constant?

Sep 14, 2009

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

View 9 Replies

String Must Be Literal. Not A Constant Or A Variable?

Jun 12, 2011

Public Class Form1
Private

[code].....

View 2 Replies

.net - Constant Values Required In Variable Declartion?

Jun 27, 2012

We are using a custom API in our project which provide an attribute for class fields/members which lets the interface to present a popup of some range values like "On/OFF" and pass the corresponding values of the choice to our code. The attribute requires a string array to know that values.We have many enumerations defined for these ranges,We are thinking to use Enum.GetValues() kind method to get a string array for this method.However, As we know the field declaration do not allow dynamic values in the declaration? so is there any other of doing same thing in efficient way.To clerify the problem i will write the examples below;

Current Working
<RangeLookUp("On:1","Off:2")> Public ASimpleRangeVariable As Integer

While I wanted to do like this or kind of

<RangeLookUp(SomeMethod())> Public ASimpleRangeVariable As Integer
Public Shared Function SomeMethod() as String()
'use Enum to get all the items as string values forexample Enum.GetValues & enu,.GetValues [code]....

Where SomeMethod suppose to return string array to be passed in the RangeLookup constructor.Which means if we change enumeration then we don't have to update the declaration.i know there are better ways to do it but due to some custom API, the ground is limited.

View 1 Replies

DLL Declaration Won't Accept Constant String Variable?

Apr 26, 2010

I'm making a call to my DLL file (prototyping 30+ functions), and want to be able to switch between different versions of the DLL quickly while in development. Thus, i want to replace the literal string constant that follows the "Lib" key word, with a variable string constant. In case there's any confusion in my use of the jargon. I am currently able to do this:

[Code]...

View 1 Replies

Forms :: Convert A String Variable To Constant

Feb 6, 2010

I am developing an application which initially allows the user to browse and select a save location. The selected path is assigned to a public variable which is used with concatenation to crate folder for saving user input data. How can I change the path string to a constant so the user can run the program again without having to run setup routine unless they want to change the save location?

View 1 Replies

VS 2005 Variable / Constant Name Held In String

Oct 13, 2011

suppose I have variables named A1, A2, A3 ... B1, B2, B3 ... Z97, Z98, Z99. I have a certain operation I want to do using each one in turn. I CAN write a line of code for every single variable, but this will get pretty tedious. I'd prefer it if I can make a function that takes the letter and the number as arguments. So, if it gets the arguments "E" and "10" it will perform the operation on variable E10. What is the syntax for this? say a simple operation such as: result = E10 * 3 Is the syntax any different if I use constants instead of variables?

View 3 Replies

Assigning A Variable A New Value?

Mar 2, 2010

'm trying to store a new value within a variable and then compare it to the previous value of that variable using the Math.Min method. I have created two seperate variable 1 for the previous and one for the new but I can't seem to store it

View 1 Replies

Assigning Value To String Variable

Feb 10, 2011

Using VB.6, I am trying to assigning a value to a string variable but it causes an error. I am doing that in following way:

Dim a As Variant

a = "<div style="width: 400px;"><img title=""

View 5 Replies

Assigning A Variable To A Class Then Storing?

Sep 30, 2009

i'm working on a code that i want to start creating new classes with but i want to know if there's a more direct way to send the variables used in the form to a new class for storage.

for example i've got this on a form...

Dim ClassID As String
Dim ClassName As String
Dim Grade As String

[Code]....

you know? so what would be my most direct route to get this? how should i start?

View 15 Replies

Assigning Gridview Check Box To A Variable?

Aug 7, 2011

This line of code references a checkbox in a Gridview, how can I assign the value of the check box 1 or -1, I think it is for checked or unchecked, to a variable so that I can run an if statement against it, and change it to True or False?

dt.Rows(row.DataItemIndex)("DisplayString") = (CType((row.Cells(3).Controls(0)), CheckBox)).Checked

View 2 Replies

Assigning Null Value To String Variable

Jul 4, 2010

How can I assign a variable which may contain a null value to a variable which is declared as Dim var1 as String and then use that variable to insert into access database table?

View 3 Replies

Assigning The Value Of A Label To A Variable Byref?

Sep 8, 2010

I would like a label to always show the current value of a boolean. This will change a lot of times and would like the label to ALWAYS reflect this.

Is there some kind of way to have the label set to the boolean byref (so its always the same). Currently I'm assigning the label.text = boolean onLoad, so if the boolean changes after that its not reflected.

View 6 Replies

Assigning Variable To A Label In Global?

May 11, 2011

I'm working on my final for VB.NET, and maybe it's just late...but here's how it goes. I need to make a variable named intMoney and it will be used to keep track of how much money you have and the value will be displayed in a label. Since this 'game' will have a lot of things going on, it needs to be available in a lot of places, not just one click event.

But I need to set intMoney to a starting value of 200 and then assign intMoney to a label called lblMoney. I can't assign intMoney to lblMoney in global. I get build errors. Where should I put the lblMoney.Text = intMoney?

View 8 Replies

VS 2005 : Assigning Date To Variable?

Feb 11, 2011

I have the following function that checks if a date is on a holiday or weekend and returns the first non-holiday or weekend date.

vb.net
Private Function CheckDate(ByVal D As Date) As Date
TempDate = D

[code]....

The function does return a date. But when I try to assign it to variable, it assigns a time instead. Both tempdate and newdate are declared as date also.

vb.net
TempDate = CheckDate(NewDate).Date

View 8 Replies

VS 2008 DataRow Not Assigning To Variable?

Apr 5, 2010

I am trying to save a row to a variable so that I can remove it from the DataTable and then add it at a different index. thing is, the row that is added is empty of the information from the data row. I'm thinking the DataRow is not saving to the variable properly. Here's my

Dim row As DataRow = dtFolderList.Rows(MoveIndex)

I'm 99.99% positive I found out how to do this like last week or soemthing but can't for the life of me remember where I found it or how to do it.

View 4 Replies

VS 2008 DataSet - Assigning Value To Variable?

Dec 9, 2009

Once I have filled a dataset is there a set of properties or in-line functions that will allow me to pull the data out of said dataset without having to populate a datagrid?
Code example:
Connection.Open()
accCommand.CommandText = "SELECT CustID FROM Rental WHERE DvdID = " & DvdID
accCommand.Connection = Connection
dvdDataAdapter.SelectCommand = accCommand
accCommand.ExecuteNonQuery()
dvdDataAdapter.Fill(dvdDataSet, "CustID")
Connection.Close()
I know the information returned from the query is a single value located at (0, 0) I just can't get to it so I can assign the value to the variable.

View 6 Replies

Import Xlsx File Into Using TransferSpreadsheet When Path Is Constant But Filename Is Variable

Oct 1, 2009

I use the followoing code to import an xlsx file into an Access 2007 table. It works fine when I enter the exact file name.However, part of the file name is a date which will change every week.The file location does not change,just the date in the file name.[code]I've tried using a wildcard but I get a Run-time error 3011.Db engine could not find the object. Make sure the object exists.

View 1 Replies

Assigning A Database Field To A Run Time Variable?

Feb 8, 2011

I just started using VS2010. I am very familiar with Visual Basic 6 and was very comfortable with it.I was able to take a variable and assign a database field to iwithout using data binding. I can't seem to figure out how to do thatin VS2010 What I am trying to do is have the use enter a password to gain access to the program. The password is stored in a database so that the user/owner can change this password to suit their preference.

View 1 Replies

Assigning Variable If Value Is Equal To This / That (Select Case)

Mar 19, 2012

I have 10 checkboxes on my screen. I have a variable setup called "case" as a string. I want to know how I can say:
If checkbox1 is checked then case would be equal to "this".
If checkbox2 is checked then case would = "that"
Example of something I tried to cook up but didn't work because it tells me that I can't only use this in a "select case".

Dim Case as string
If checkbox1.checked = true
case = test1
end if
If checkbox2.checked = true
[Code] ......

View 5 Replies

Execute A LINQ Statement Without Assigning It To A Variable?

Apr 15, 2011

I have the following function

Public Function GetPositionBySchoolID(ByVal SchoolID As Integer) As CPAPositionsDataTable
Dim positions As New CPAPositionsDataTable

[Code]....

And I was wondering if there is any way to cut out assigning the LINQ result to tmp and just work with the result directly, i.e.

Public Function GetPositionBySchoolID(ByVal SchoolID As Integer) As CPAPositionsDataTable
Dim positions As New CPAPositionsDataTable

[Code].....

View 2 Replies

SELECT From An SQLite Database And Assigning It To A Variable

Dec 21, 2009

I am trying to retrieve a password from an SQLite database. The id of the row the password is in is 1. I want to assignt his password to a variable called actualpass.[code]

View 1 Replies

VS 2008 - Assigning Decimal Type Value To Variable?

Sep 8, 2010

I want to assign a Value to a Variable of Decimal Type to do a calculation, but when I enter the decimal value (a 28 digits to the right of the decimal point - very long numbers) it gets altered. I give below what I was doing:
Dim MyNumber As Decimal = 0.7777777777777777777777777774

But as soon as I finish typing the number, it becomes 0.77777777777777779 and appears as,
Dim MyNumber As Decimal = 0.77777777777777779

And, when the cursor is kept over the altered number it shows as "Double, Represents a Double - precision floating-point number." How can I get the value I wanted to stay without getting changed? I was able to get this long Decimal value as the result of a calculation and get that appears in a text box in the same program. Is there anything I should change in the "Visual Studio 2008" to get this ?

View 5 Replies

VS 2008 Assigning Form Pointer To Variable?

Aug 31, 2010

What I want to do is either trivial, or likely impossible in the .NET framework.

I have a number of forms, with various pictureboxes, labels, etc. in each. Same names for the same items on each form. Only one form is visible at a time. What I need is some way to assign to a variable in the code which form is currently in use, such that I can reference the control on that form in a single statement.

That is, I have set up (already) references to the individual forms (call them frmForm1, frmForm2, etc.). So I can write to a textbox as:

frmForm1.textbox1.text="Hi there."
frmForm2.textbox1.text="Hello world."

What I need to be able to do is something like:

currentform = frmForm2
currentform.textbox1.text="Display on visible box"

Is such a thing even possible? Obviously, the way .Net normally wants to work is to verify everything at compile, and there is (of course) no way for it to know if whatever "currentform" points to even has a "textbox1" control.

save me a LOT of long-winded IF-THEN-ELSE to see which form is currently displayed for each and every time I want to display something. [FWIW, I *could* right everything out to every form, but I feel that would waste to much CPU time.]

View 6 Replies

Asp.net - Taking A NULL Value From The Database And Assigning To A Date Variable

Mar 11, 2009

A stored procedure returns data about a user record including a nullable datetime column for their last login date. Which one is the better choice in dealing with the possibility for NULL values when trying to assign a .Net date variable?

Try
_LastLogin = CDate(DT.Rows(0)("LastLogin"))
Catch ex As InvalidCastException

[Code]....

Which is the preferred method of handling possible NULL values from the database? Is there a better way than the three listed?

Edit #2: I have noticed that the TryParse method does not play nice when trying to assign to a Nullable type.

View 5 Replies

Assigning A File Path Using Text From Different Controls To A Variable?

Aug 10, 2009

I would like to create a filepath and assign it to a string (so that it can have yet more added to it later on in my program) the code takes (well i want it to but it doesn't) the name of a drive selected previously and then adds this to a string to create a string variable that refers to a file. and then (as usual) i want to use thes files and display them in a combobox but i want to only select files that have a pre selected 2characters at the front. I have got this code so far:

' search for filer drive NETAPP-1
For i = 0 To frmDatabase.drvDB.Items.Count - 1
If InStr(frmDatabase.drvDB.SelectedText(), "\Netapp-1malika", CompareMethod.Text) Then

[code].....

View 6 Replies

Assigning The Collection Returned By Computer.FileSystem.GetFiles To A Variable?

Sep 14, 2010

Do you know how to declare a variable that can hold the result of a call to GetFiles?

I don't know how to do this, so I am using the following verbose/duplicative version:
Dim l_v_String_FoundFile As String
If My.Computer.FileSystem.GetFiles("A:u_Au_W", FileIO.SearchOption.SearchAllSubDirectories,

[code].....

View 5 Replies

Assigning The Collection Returned By My.Computer.FileSystem.GetFiles To A Variable

Mar 10, 2012

Do you know how to declare a variable that can hold the result of a call to GetFiles?

I don't know how to do this, so I am using the following verbose/duplicative version:

Dim l_v_String_FoundFile As String
If My.Computer.FileSystem.GetFiles("A:u_Au_W", FileIO.SearchOption.SearchAllSubDirectories, l_v_String_FileMask).Count = 1 Then

[Code].....

View 14 Replies

Datagridview/Query - Finding Highest Number And Assigning It To A Variable?

Jan 9, 2010

I don't know if I worded this properly, but I have a mdb query that I display in a Datagrid on my form. The first column is TransactionNumber, which is the primary key and a running total (ex. RackingTransactionKey=RackingTransactionKey + 1). What I need to do is when the form is opened, find the highest (last) TransactionNumber from the query or Datagrid and assign it to a variable (RackingTransactionKey), so I can can update it (+1), therefore generating a unique number so I can add data to the query.

[Code]...

View 13 Replies

Making Quiz - Assigning Point Value To Variable Depending On Answer

Nov 15, 2010

I am thinking is to have a question, then between 2-4 answers, and depending on the answer a point value gets assigned to a variable, but then when that one question is answered you can click a button that moves to a next page type of thing with a new question on it. I think I could probably figure most of this out but when it comes to switching to a different question I am not sure how I would do that.

View 11 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved