VS 2010 Anyway To Customize A Variable To Use Both Integer And Boolean Value?
Aug 19, 2011
Is there anyway to customize a variable to use both an integer and a boolean value?For example. I am kind of making a simulation engine and using GDI as a visual aid, I am generating a grid of tiles for objects to be displayed, but I do NOT want to repaint all the tiles just the ones that have changed, so that I can save fps.So I thought if I could set a variable for the "tile number", "how many objects there are on a tile", and a boolean value for whether or not the tile needs repainted.[code]
View 2 Replies
ADVERTISEMENT
May 28, 2009
I'm just writing a bit of code to compare an id of integer with an id of integer? for example:
Dim id As Integer = 1
Dim nullId As Integer? = Nothing
Dim areEqual As Boolean
areEqual = nullId = id
When I try to compile the code I get a compiler error: Option Strict On disallows implicit conversions from 'Boolean?' to 'Boolean'. Whilst it's very simple for me to work around this, I was hoping that someone might be able to explain what's going in the compiler to give this warning.
View 5 Replies
Jun 2, 2011
Say I have something like this
Dim Level1 as Integer = 83
Dim Goal as String
Goal = InputBox(" What level is your goal?")
[code].....
View 7 Replies
Aug 1, 2009
I am interfacing my pc to a device called a MiniBee which is basically a usb digital output adapter to allow electronic devices to be controlled by the pc. So, I need to be able to individually address the output channels of this device, the only problem is the DLL supplied with it will only accept an integer value which represents a binary instruction if that makes any sense. I have basically got 8 public boolean vars OUT1, OUT2 etc that I need to use to turn on/off the outputs by them being set to true/false.
So there are say 8 digital output channels to operate and it has to work like this:
SetOutputs(1) would turn on output 1 and turn all others off
SetOutputs(2) would turn on output 2 and all others off
SetOutputs(3) turns on 1 and 2 and all others off
How to turn my public bool vars into an integer based on what is set to true/false if you get my meaning as there must be an easy way but working it out individually there are far too many possible permutations.
View 1 Replies
Jan 17, 2011
This is probably a really basic (no pun intended) question, but I can't seem to find an answer anywhere.Why does the result of func1 return False and func2 returns True? On every other test I have done, integer 1 is converted to boolean true and 0 to false. Works ok if I just set rtnValue to 1 or 0.
View 3 Replies
Sep 1, 2010
I am working with some VB.Net code that seems to be casting a boolean value to an integer using CInt(myBoolean). The odd thing that is happening is that it returns -1 if the value is true. For example:
CInt(True) // returns -1
CInt(False) // returns 0
Is this common in other languages? I thought that a boolean would be 1 if true and 0 if false. Also, is there a way to make VB assign 1 to true instead of assigning -1?
View 5 Replies
Jan 24, 2012
Dim method1 = Function(x As Integer, ByRef y As Integer) As Boolean
If x = y Then
Return True
Else
[code]....
View 3 Replies
Jul 14, 2009
I am looking to convert an integer into a boolean array where each item in the array corresponds to a bit in the binary representation of the integer.
MyInteger = 3 '011 in binary
to
MyArray(2) = False
MyArray(1) = True
MyArray(0) = True
Also is there anyway to assign a value to an Integer in binary or hex (like MyInteger = 1010b or MyInteger = A7h)?
View 20 Replies
Dec 13, 2011
If I try to put a string into a Boolean variable such as this:
Dim testValue As String = "True"
Dim bool1 As Boolean = testValue
With Option Strict On I get an error and the suggested fix is to change the second line to:
Dim bool1 As Boolean = CBool(testValue)
This is fine, But - what are the advantages / disadvantages of doing this instead:
Dim bool1 As Boolean = Boolean.Parse(testValue)
View 4 Replies
Nov 15, 2011
I am developing an application for multi user using vb.net with back end as ms-access. For the table name as employee_master, there is a column, name as student_profile having datatype as Yes/No .
[Code]...
View 1 Replies
Aug 18, 2010
I am trying to up a private sub routing based on the Text Changed Event for a listbox, inside of the event, I want to set a boolean variable to true. I have it set up, but for some reason it is not getting called.
Basically what I am doing is the user is being prompted to enter data in an input box. I am taking the data that is entered on the input box and populating it in a list box. I want to know if the text in the listbox has been changed, hence changing the blnIsChanged = True
Can I use text changed with a listbox???
View 2 Replies
May 5, 2011
So I had a smart idea to make a dictionary with all my variables so I could save them easily in chunks. This includes String, Boolean and Integers. When I was in Framework 3.5 I only had a few warnings about stuff that I didn't have coded in, but now in Framework 4 I am maxing out all my warnings with Implicit conversions. Personally I don't want to go to every number and put quotes around it put quotes around "True" because then it may change the method.
Public Function loadGeneral(ByVal fName As String) As Boolean
Dim tempDict As New Dictionary(Of String, String)
For Each kvp As KeyValuePair(Of String, String) In GeneralSettings
Dim v1 As String = kvp.Key
Dim v2 As String = QuizZing.My.Settings.GetSetting(fName, v1)
[Code] .....
View 14 Replies
Nov 17, 2009
From what I read it is a good convention to name a method that returns a boolean value with the prefix of "is" or "has". So in keeping with this convention I am trying to name a method in my program with this prefix but I am running Specifically I have a class called Day. It is a simple class with a few data members and one method that returns a boolean value of true or false. The name of the boolean variable is isSpecialDay. This class has a method called isSpecialDay which takes the date of the day, applies some criteria to the date and then sets the variable isSpecialDay to true or false. My problem is that the boolean variable is named isSpecialDay and so it the method. What should I do?
Public Class Day
Private TheDate as String
Private DayName as String
[code].....
View 8 Replies
Jul 10, 2011
I just need some syntax that will tell if a variable is an integer or not. I want to do something like this (i know this isn't correct syntax but this is the general idea):[code]
View 19 Replies
Apr 27, 2012
In my assignment, i need to Swap of two integer variable without using third with VB.NET code. But, i still have no idea of how to do.
How can i do this with coding?
View 6 Replies
Jan 27, 2010
How would i create a variable for EVERY form, so that i could add/subtract from it no matter which form i'm on.
View 10 Replies
Jan 31, 2010
sgBox("********" + Microsoft.VisualBasic.Right(f, Len(f) - Len(vFilepath)) + " | File so ignored | " + i) where i is an integer, f and vFilepath are strings but I get the following message:Conversion from string "********~$SwitchSellReport - 230" to type 'Double' is not valid.All I want to do is put the number that is in i on the end of the string.
View 5 Replies
Aug 23, 2011
I have got the following
PHP MsgBox("********" + Microsoft.VisualBasic.Right(f, Len(f) - Len(vFilepath)) + " | File opened so ignored | " + i)
where i is an integer, f and vFilepath are strings but I get the following message:
Conversion from string "********~$SwitchSellReport - 230" to type 'Double' is not valid.
All I want to do is put the number that is in i on the end of the string.
View 2 Replies
Oct 21, 2011
Doing a calculation, variable is stored as an integer.It got too 2,147,483,647 before giving me an arithmetic overflow. Anyway i can increase the number it can hold?
View 7 Replies
Jul 5, 2010
Convert String Variable to an Integer?
I tried this[code]...
View 10 Replies
Dec 18, 2009
I don't think I fully understand passing values from a sub to a module. Here is what I'm trying to do (problem is at the '****):
[Code]...
I think I've seen something like this before - where the actual function returns a value. Is this possible? Or would I have to pass an integer variable from the sub to the function, and then return it back to the sub?
View 3 Replies
Apr 21, 2010
There are a lot of interesting methods buried in VB.NET, and I'd hate to miss the one that "flips" a Boolean value.
What I'd like to do is something like:
Dim MyBool As Boolean = False
If <true statement> Then MyBool.FlipValue
Of course no method like that seems to exist in the Boolean type itself, but maybe there's another single-statement method that will accomplish the same thing.
View 3 Replies
Dec 16, 2010
Using a "Numeric up down" or text box, how would i save the number the user picked to a variable and then add two to that number?
View 4 Replies
Mar 16, 2010
Is it possible to make a variable hold a reference to an integer instead of copying its value when using integerVariable = integerValue ?
View 2 Replies
Apr 26, 2009
I have a problem when debugging a code. On top of class I declare an array, and the length of array is an integer variable which is applied value below declaration of array.
E.g. class declaration
Dim array1 (2, integer) as string
Public Sub
integer = 5
End Sub
So basically, array is created with integer being 0 or whatever, because it is declared before integer was assigned a value. But the problem is, I need it to be declared at class variable so I can use array in different subs.
View 3 Replies
Jul 19, 2011
Is there a way of testing to see if a number variable is an integer, or a decimal?
View 8 Replies
Feb 3, 2011
I just found an error in the compiler. Newpath is a boolean and the compiler took and ran this[code....
View 1 Replies
Apr 1, 2011
i have problem when save boolean value to database. this my code vb.net
if bAdd then scmd.CommandText = "insert into products(prod_id,status) values(@prod_id,@status)"else scmd.CommandText = "update products set status=@status where prod_id=@prod_id"end if scmd.Parameters.Add(New OleDbParameter("@status", CBool(chkStatus.Checked))) scmd.Connection = dbConnDim iResult As Integer = scmd.ExecuteNonQuery
i get problem when execute query at line
scmd.ExecuteNonQuery
Data type mismatch in criteria expression
View 8 Replies
Jun 16, 2011
I am working with a multi form project. The long and short of it is that when i originally load form 1 ... all bool variables are false. Once i load form 2 and perform my operations some of my bool variables will be set to true.
I need to have some sort of object to listen for those changes. What i have come up with so far is the following. Private Sub patient_frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code]...
The if statement will work but i need a way to make it keep looking for changes in the boolean variables.
View 1 Replies
Sep 19, 2011
What is a Boolean and what does it do in Visual Basic 2010?
View 8 Replies