Pass In An Operator?

Jul 4, 2010

Is there any way to pass in an operator in VB.NET? I'm looking to reduce my lines of code and for two functions there is literally only an operator that is different.For example, I have two functions, Darken and Lighten. I'd like to get to a single function with as little code as possible. The only difference are Greater Than and Less Than operators.

Function Darken(ByVal clr1 As Color, ByVal clr2 As Color) As Color
Dim newR = If(clr2.R < clr1.R, clr2.R, clr1.R)
Dim newG = If(clr2.G < clr1.G, clr2.G, clr1.G)

[code].....

View 5 Replies


ADVERTISEMENT

Pass An Operator As A Value On A Function?

Jun 27, 2012

The is a calculate function for example Function Calculate (Byval v1 as integer, Byval v2 as integer, byval op as ????????) as double return v1 op v2

End Function Anybody tried this?

I don't want to use functions for every operation (multiply,divide, etc.). I wanna pass a operator same as I pass the values. How come nobody ever had this need in VB? Using enums could work but still...

View 1 Replies

Error: Option Strict On Disallows Operands Of Type Object For Operator '='. Use The 'Is' Operator To Test For Object Identity

Jan 27, 2010

I am tightening up my coding with the Option Strict set to ON. It has now produced alot of errors. An example of this is:

If AllocatedDGV.Rows(i).Cells("RoomNumber").Value = RoomsAvailableDGV.Rows(j).Cells("RoomName").Value Then

It gives me the following error: Option Strict On disallows operands of type Object for operator '='. Use the 'Is' operator to test for object identity.

View 6 Replies

Option Strict On Disallows Operands Of Type Object For Operator Use The 'Is' Operator To Test For Object Identity

Apr 6, 2012

I need to write an interface to get data to/from our data files.

We have a low level class that holds field values for each record read from the files.

This just holds two values, the value read from the file (DBValue) and the updated value that may need to be written back to the file (CurrentValue).

These values may be any of the standard value types (integer, date etc) or a string.

Either value (DBValue or CurrentValue) may be null if not defined.

I have written the class to manage this data which works fine while option strict is NOT on.

But we have an office policy of having option strict on all the time.

When I put option strict on, my object value comparisons fail with the error: "Option Strict On disallows operands of type Object for operator '='. Use the 'Is' operator to test for object identity."

Question, how should I change the following code to handle option strict on ...

This is all running on Visual Studio 2010

[Code]...

View 1 Replies

Coalesce Operator And Conditional Operator In .NET?

Mar 10, 2009

Possible Duplicate: Is there a conditional ternary operator in VB.NET?

Can we use Coalesce operator(??) and conditional ternary operator(:) in VB.NET as in C#?

View 5 Replies

How To Use Operator As A Comparison Operator

Nov 11, 2009

I want to perform equality comparison in VB.NET and cannot get it to work. Error: value of type Boolean can not be converted to System.Drawing.PointF

[code]...

View 4 Replies

VS 2005 Update Table - If All Results Is PASS Then The Table2 Should Be Updated As Pass

Jun 8, 2012

I have two tables:

table1

case_no flow result
tc_1 001 pass
tc_1 002 pass
tc_1 003 pass
tc_2 001 pass
tc_2 002 fail
tc_2 003 pass


table2"

case_no result
tc_1 pass
tc_2 fail

Table2 should be updates from table based on the results... If all results is PASS then the table2 should be updated as pass... if any result is FAIL then the entire case_no should be updates a s fail..

View 7 Replies

Sockets - VB9 .Net 3.5 (2008) Code Works On The First Pass.Then Second Pass It Just Hangs On

Jun 19, 2009

This code was working consistently, but now...This code works on the first pass.Then second pass it just hangs on Code:Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient() for about 2 minutesThen the code will fork for another pass, then fail.....

Code:Imports SystemImports System.TextImports System.Collections.GenericImports System.XmlImports System.Xml.LinqImports System.Net.Sockets

[CODE]....

View 2 Replies

Pass Data To Dialog - Manipulate And Pass Back?

Jan 15, 2010

Just started VB programming this week and have found a wealth of information about what I'm trying to do. Problem is, some of it is more complete than others.Here's what I'm trying to do:In Form1 (my main form), I want to instantiate a class that contains a couple of properties (speed setpoint and position setpoint). When I click a button, I want to pass this data to Form2 and populate two textboxes on Form2 with the properties of this object. I want to manipulate the property values on Form2 and click an OK button which closes the dialog and returns the manipulated data, updating the property values of the object. Here's the algorithm I'm following:1) On Form1, instantiate the class2) On Form1's "Pass Data" button click event handler, instantiate a Form2 object and invoke the ShowDialog method, passing the object as a parameter.

3) On Form2, overload the ShowDialog method to accept the object as a parameter and modify the method so that it returns the manipulated class data.4) On Form2, in the ShowDialog method, populate the textboxes with the class data that was passed in.Here's where I get stuck. If I press the OK button on Form2 (DialogResult.OK), it returns me to Form1, but what hook do I have in Form1 to receive the manipulated class data that the ShowDialog method is returning?Here's an example of what I'm thinking about:

Code:
Public Class Form1
Dim clsController1 As New MotionController

[code].....

I'm sure it's probably a very elementary question, but every explanation I've found seems to be incomplete.

View 2 Replies

VS 2005 To Pass Or Not To Pass?

Apr 16, 2009

I am looking for some input. I am helping with a web application that is fairly large. We have some logic factored out into classes, not a true business logic layer (yet ). The classes are setup to pull values directly from the QueryString or Session variables and I'm not sure that that mehtod is proper or even a

The reason I would like some input is, there may be a chance to rewrite or at least refactor the code.

[Code]...

View 2 Replies

What Is A ! Operator

Aug 5, 2009

What does the ! mean in the following code snippet?Availability is a table in an access database Family and Model are column headers in the table cmbFamily and cmbModel are combo boxes.

If Availability!family = cmbFamily.Text Then
cmbModel.Items.Add(Availability!model)
End If

add the models of as aircraft family to a combobox(cmbModel) using a selection from another combobox(cmbFamily).

View 10 Replies

.net - VB Or Operator On Int32 And Int?

Oct 13, 2009

whats do Or operator in Vb do when it is applied as follows eg

Dim returnValue As UInt32
Public Const RMA_VC_RET_NULL_PTR_PARAMETER = 1
returnValue = returnValue Or RMA_VC_RET_NULL_PTR_PARAMETER

what does the 3rd statement do?

View 1 Replies

Byte And The And Operator?

Mar 28, 2012

Dim bteJustTheAddress As Byte bteJustTheAddress = RawData(2) And &H7F

RawData is a Byte Array and I know &H7F is the Hex 7F

View 3 Replies

C# - No Increment Operator In .net?

Jun 14, 2011

came across this issue while converting a for loop in C# to VB.net I realized that the increment operators are not available in vb.net (++ and --)whereas i was able it do something like cnt +=1 .In VB, a STATEMENT cannot be just an EXPRESSION. why this doesn't work in the same way as it does in C#.

View 4 Replies

C# - What Is Purpose Of '' Operator In Vb

May 16, 2011

I want to know what is purpose of '' in vb ? I have this statement: frontDigitsToKeep 2 and I want to convert it to C#.

View 2 Replies

Consider Operator Overloading In .net?

Sep 9, 2009

What scenarios would you consider operator overloading in .net?

View 5 Replies

Get Data Using Like Operator?

Nov 25, 2011

I am trying to get data from my Access database using like operator. For example my ProducID contains NoteBook, Notes etc. Using like operator, I want to get them all shown if user types No etc.Like operator did not give any errors but it only shows record when I put full NoteBook (does not show for Notes offcourse)

View 2 Replies

How To Use Operator Like In Bindigsource

Nov 3, 2009

how to use? operator Like in Bindigsource? for Exmaple :

BindingSource1.Filter=" Feild1 Like N'%" & TextBox1.text & "'%"

that Code is false,Becuse hase an error?

View 3 Replies

If Statement With NOT IN Operator?

Mar 31, 2011

s it possible to use NOT IN operator in If Statement?i.e. If strPara NOT IN (strCompare1,strCompare2) then exit sub

View 17 Replies

Is There A ?: Operator Equivalent In .net

Jan 21, 2010

Is there a ?: operator equivalent in .net? eg in java I can do:

[Code]...

I'd like to be able to do similar in VB.NET.

View 1 Replies

Make Operator In C#?

Aug 25, 2011

I'm converting vb code to c#There is enum from telerik library:

namespace Telerik.Windows.Controls
{
// Summary:

[code].....

View 3 Replies

Operator '&' Is Not Defined?

Feb 15, 2009

Error1Operator '&' is not defined for types 'String' and 'System.Exception'.L:\Programming\thingy\Mail.vb3720thingy

not much else i can think to add here but it's making it hard to work...i'm using it like...

Dim Temp As String = "Hello" & vbCrLf & "Hi Again"

View 5 Replies

Operator '+' Not Defined

May 16, 2010

I'm having an error on the red font ...it says operator '+' not defined for type dbnull and type dbnull [code]...

View 7 Replies

Operator In Row Filter?

Sep 15, 2010

By Using

dv.RowFilter = "Convert([OIMainID], 'System.String') Like '" & OIMainIDTextBox.Text & "%'""

i'm almost getting the result i want. What i want is an exact match in the filter so if the box only contain the number 1 to will only show rows with the number 1 and not return say 12 13 14 etc etc, and vice versa for other numbers.

View 2 Replies

Randomize The Operator?

Dec 17, 2009

how do i randomize the operator?? i mean i wan the operator occur to be in random .i have to rush out my miniproject on next wednesday so i do ask the problem i meet here

View 5 Replies

Two Datasets In If Operator

Jan 8, 2010

i want to check if datasets have changes and after that use msgbox (vbYesNoCancel) when program closes ,when i wrote this code it had error "Operator 'Or' is not defined for types 'System.Data.dataset' and Boolean"..[code]

View 2 Replies

Using The 'And' Operator Properly?

Apr 8, 2010

In the project�s btnReadNumber click event handler, replace the code in the try section of the try/catch block � the two if statements and the unconditionally executed code � with one if-else statement that performs the same tasks. Use the And operator to write the if-statement�s condition.What I don't understand is how am I supposed to use the 'And' operator so that when I insert a number between 32-16384 in the text box it'll allow it to go through and at the same time not allow any numbers lower than 32(lower_bound) and higher than 16384(upper_bound) to go through.I've use the 'Or' operator and that was simple, but with 'And' I'm not understanding it.Remember it has to be with the 'AND' operator. I bold the area where my problem is at. It's obviously not the right answer, but that's where I was stumped.

Dim sum As Integer = 0
Const upper_bound As Integer = 16384
Const lower_bound As Integer = 32

[code]....

View 4 Replies

VB Equivalent Of C# Operator?

Jul 2, 2010

Possible Duplicate: Is there a VB.NET equivalent for C#'s ?? operator? Is there an equivalent in VB.NET to C#'s ?? operator?

View 1 Replies

What Is The Equivalent Of ^ Operator In C#

Apr 20, 2012

What is the equivalent operator in VB.Net for ^ (this is for C#)

View 6 Replies

What's An Example Of An Overloaded 'And' Operator

Nov 21, 2010

So Google's not a good choice for looking up examples for overloaded operators like "And" or "Or", because it tries to parse them as operators to the search query itself. MSDN also provides no examples of how to implement an overloaded And operator, so I'm not certain how to properly overload it for my project.Does anyone have an example of "And" at minimum? "Or" or "Xor" (or any others) would be a bonus. I'm not certain if I need to overload these operators in my objects just yet, as I'm still building them out and haven't planned beyond just yet. But having examples around that might get indexed by Google will probably help save the sanity of a lot of people...

View 2 Replies







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