.net - Boolean VB Expression Returning False For Integer 1?
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
ADVERTISEMENT
Jan 18, 2010
I'm pretty new to Vb so I'm not sure of all the correct terminology etc.
Private Sub Add_mousedown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.MouseDown
Dim Addition As Boolean
[code].....
View 2 Replies
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
Jan 26, 2011
coming from this question i was wondering why:
[Code]....
'this throws an "Object reference not set to an instance of an object"-Exception'
[Code]....
A CType(obj, Boolean) would evaluate to False(just as CBool(obj)), i think because the compiler uses a helper function, but that is not my theme. Why does casting Nothing to Boolean evaluates to False, whereas casting an object that is Nothing to Boolean throws an Nullreference-Exception? Does that make sense?
View 4 Replies
Aug 2, 2010
A week or so ago, you folks really taught me how to use the KeyData event. I adopted some of the coding to make my new code so much better. A few days ago, I thought I figured out how to run my little game. You see, you have two buttons. Comment and Uncomment. You Press Control + K and then after that, you press Control + (C or U) to activate the buttons. And I thought it worked! But my buddy figured out how to break it! The thing is, I need to figure out a way to make IsCtrlK (Look below) False if any key that isn't Control + C or U is pressed right after it. What would you suggest I look into using?
[Code]...
View 4 Replies
Jul 28, 2011
I have a math program that I am working on. One of the exercises has a random word and 6 radiobuttons. The user has to select the radiobutton that displays the exact number of letters in the random word. What I am having trouble with is creating a Public Function to check if the answer selected is the correct one. The radio buttons are within a groupbox. The Public Function returns a boolean True or False.
View 4 Replies
Mar 14, 2012
I'm making a class and I have a function in this class the is looking to see if a user account in enabled.
Public Function IsEnable(byval user as string) as boolean
'if user is enables
return true
else
return fulse
end function
What is it just does not find the user, how would I return an error that the person using the DLL could detect and catch?
View 2 Replies
Aug 11, 2011
I faced an error when upgrading VB6 code to VB.NET. The error occurs at AddressOf WindowProc
AddressOf expression cannot be converted to 'Integer' because 'Integer' is not a delegate type
My declaration for SetWindowLong is:
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"(
ByVal hWnd As Integer,
ByVal nIndex As Integer,[code]....
What is the reason for the error I get?
View 1 Replies
Aug 3, 2009
I am a newbie in VB and I got a piece of code which can display the current running program. I need to use that in VB2005 and I got the below error message. Can anyone help how to fix it?[code]
View 18 Replies
May 13, 2009
I'm trying to convert a VB6 project to .NET, but I get problems with some callback functions, and the following message comes up: "AddressOf' expression cannot be converted to 'integer' because integer is not a delegate type" I've seen several solutions to similar problems like this, but I am not able to understand this issue with delegates.
After the conversion, the code look like this:
Declare Function vsmsgwSetDataPackageCB Lib "vsmsgwW.dll" (ByVal PACKAGE As Integer, ByRef arg As Integer) As Integer
Dim arginitP As Integer
[Code]...
Which gives the error: Method 'Public Function PackageCB(HisNodeID As Integer, ByRef data() As Byte, ByVal length As Integer, ByRef arg As Integer) As Integer' does not have the same signature as delegate 'Delegate Function DelegatePackageCallback(hwnd As Integer, lparam As Integer) As Integer
View 1 Replies
Sep 21, 2011
I have a HTTP class that gets content from URL's, POST's content to URL's etc and then returns the raw HTML content.In the function inside of the class it detects if there is a HTTP error and if so I would like to return false but will this work if I have declared the function to return a String?
Code Sample of what I am trying to do (Note the Return Content & Return False if a HTTP error code is detected)Public Function Get_URL(ByVal URL As String) As String
[Code]...
View 1 Replies
Oct 15, 2011
I am new to programming.I am making a coin tossing program for class.It is telling me I need to create a separate method that doesn't take any arguments and only returns false for tails and true heads.Not sure if a function or a sub returns only that type of data. Also once the code is returned I can then add that to a CONST to keep a running total.If the method only returns true or false do I need to put the code in buttonclick sub to post the image of the coin in the picturebox using a if then statement? Would I also need to add the code for the print out of the statistics after the if then statement? Not asking for code just a step in the right direction.
View 4 Replies
Mar 26, 2009
I'm not reciving any errors at all this is Still my homework on the Compound Intrest and it's due tommarow and well an if statement isn't working
Private Sub btnCalc_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles btnCalc.Click
Dim decAmount As Decimal = 0D
[Code].....
View 6 Replies
May 24, 2012
I have the following test code. It does nothing useful, but it's there for me to understand VB:
Imports System
Imports System.IO
Imports System.Diagnostics
[code].....
View 1 Replies
Apr 4, 2012
I've read a few articles talking about checkboxes always returning a false state,[code]I though it was due to the second input that it was always returning a false state.
View 3 Replies
Jun 5, 2010
"In what circumstances will the following boolean expression evaluate to true?
strAlphabet.indexOf(StrCharacter) >= 0 And _
strAlphabet.indexOf(StrCharacter) < 0
Once you have answered that question, you should be able to complete this description: the expression indicates whether strCharacter is ..... but is not...."
View 39 Replies
Mar 18, 2011
I have a basic bubble sorting algorithm that can sort either A-Z or in numerical order with just the change of a "less than" or "more than". However, I have to use the code twice in order for it to sort correctly.
'Sub Sort(ByVal array As Object)
'--A-Z
If Array(i) > Array(i +1) Then
[code]....
Anyway, if there is a way to do it, that'll allow me to have just one sort instead of having two sorts which use the same sorting algorithm, but just a different comparator.
View 2 Replies
Jan 22, 2012
I have a GridView with a Checkbox on the first column: Code: The thing is that the Checkbox.Checked always returns False. How can I get the checked state of the Checkboxes in this scenario? Or what would be the best approach into updating the aforementioned column? P.S. Note that click on the checkboxes doesn't post back. Nothing happens on the page until the user clicks Save (and that is the intended behavior).
View 2 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
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
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
Jun 24, 2011
I am developing a VB.NET ASPX file and am trying to run a string query in VB.NET, but now I get the above error message. How can I determine the cause? Some of the code in this
[Code]...
View 2 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
Jan 21, 2011
How come both intellisense and compiler accepts If 3 = True Then ... in VB.NET? Even with option strict on.Does it in actuality treat Booleans as Integers, or what's the deal?
View 4 Replies
Aug 6, 2009
While testing some code i found something strange how vb.net (2005) is handling integer representation of true and false (or yes and no). Or at least i dont understand the reason for this.Im used to C or Java where 0 is false and everything else is true. To get to the point, here is the code: [code] And the out put is:X: 1 Y: 2x is truey is truex and y is false.If x and y or both individually true, why does it return false when you evaluate x And y.However, change the values of x and y to 4 and 5 you get this:X: 4 Y: 5x is truey is truex and y is trueJust another example, which seems to work how it should to me:X: 4 Y: 0x is truey is falsex and y is false.
View 7 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
Nov 18, 2010
I am finding this weird issue. When I do this > activities.Where(Function(a) (Not a.IsDeleted And a.ParentId = 100) It returns an in-memory query & when I try opening it up, it throws a object not set exception. This only happens when there were no items which satisfied the condition. Shouldn't it be returning an empty set? When there are items satisfying the condition, then it returns a list & works all good.
View 1 Replies
Oct 13, 2009
im converting a vb code to vb.net from simpleocr site but i can't run this code because of error in sub calling (ret = objOCR.OCRSetOutputHandlerX(AddressOf myOutputHandler)) :
Code:
'AddressOf' expression cannot be converted to 'Integer' because 'Integer' is not a delegate type.here's the code:
Code:
dim strOCRResult as string = ""
Private Sub DoOCR (filename as String)
Dim objOCR as SimpleOCR 'SimpleOCR object
[code]....
View 7 Replies
Jan 23, 2011
im converting a vb code to vb.net from simpleocr site but i can't run this code because of error in sub calling (ret = objOCR.OCRSetOutputHandlerX(AddressOf myOutputHandler)):
Code:'AddressOf' expression cannot be converted to 'Integer' because 'Integer' is not a delegate type.I googled around but i did not found any solution here's the code:
[Code]...
View 2 Replies
Mar 26, 2010
I'd like to understand why one type can't be converted to another type inside a constant expression.
View 13 Replies