Custom Structures And The Old Equals Sign?

Apr 2, 2011

Well I thought this was going to be easy, then the problem showed up.So I have a structure defined, as follows:

Structure Testing
Dim i as short
Dim j() as short

[code]....

And I need to do the same with all of the T2 array members.Now I get into writing the real code. Something like this:

For i = 1 to 100
Populate portions of T1 'not all values of T1 are used for each value of i
T2(i) = T1
Reset T1 to zero values and empty strings
Next i

So what is going wrong? After I set my T1 components back to zero, my T2(i).j has had all its 1-10 index values set to zero. Note that it is just the array, not the string s or the non-array i.Sure, I could write some code where I set T2(i).i = T1.i, and so on for each variable in the structure. But I have a feeling that is not the right way. There is some kind of equivalence going on between T2(i) and T1 in each loop. And I would would like to understand that more so I know how to really deal with it.

View 9 Replies


ADVERTISEMENT

.net - IEnumerable.Equals Seems To Call The Wrong Equals Method

May 23, 2012

I implemented a PagedModel class to wrap around IEnumerable to provide paging data for grids in my MVC app.I used Resharper's auto-generated Equality code telling it to check the data, total rows, page number, and page size fields.[code]I found the call to Equals(other._ModelData, _ModelData) peculiar, as AFAIK, this checks that it is the same object rather than that the contained items are the same. Because my tests were failing anyways, I went ahead and changed it to other._ModelData.Equals(_ModelData) with no success. Then I reflected into it at debug time and found that other._ ModelData.GetType().GetMethod("Equals",{GetType(Object)}).DeclaringType was Object! Obviously, that would result in the failed comparison.I came up with a solution to create a EnumerableEquals method which compares every item in the two enumerables to confirm the are the same, but it seems sloppy. Is there anything I can do to use the normal .Equals method? [code]

View 2 Replies

Sign Converted To [] (square Sign) When Importing

Dec 1, 2010

Im importing text from a .txt file using streamreader and when it reads in a � sign it converts it to the square symbol for a unknown character! If i put in a $ sign it imports it correctly!

View 2 Replies

(2005) Arrays Of Structures Within Structures?

Jan 20, 2009

I have a structure called 'Scheme' and in my program I want (ideally) an ArrayList of 'Schemes' (so i can add, remove schemes etc.). However, within the 'Scheme' structure, I want to have an ArrayList of 'Item''Item' is another structure. Are there any solutions out there for iterating through these arrays quite easily?

How can I easily add multiple Items to a Scheme and mutliple Schemes to my Scheme array. Code is below. When I try to add Items to a Scheme, I get the 'Object not set to a reference of an object, try the 'New' keyword', but you cannot declare 'New' keywork within a structure.

[Code]...

View 4 Replies

Structures And Arrays Of Structures?

Jun 2, 2010

I read in the Book "Mastering Microsoft Visual Basic 2008" about "User-Defined data types".The example given is creating a Structure as follows.I wanted to check that so I wrote all the code given; I used a TextBox and a Button for this.(I didn't include the "CheckDate" here; that is in the book)

Structure CheckRecord
Dim CheckNumber As Integer

[code]....

The problem is this does work.What I get is "00000". and I found out that the "Checks(4)" Array does hold any value ie: on keeping the cursor over that, it shows "CheckAmount 0.0, CheckNumber 0 , CheckPaidTo Nothing ".

View 1 Replies

Using String.Equals In .net?

Aug 26, 2011

I am comapring 2 contract IDs, one is sent by the caller, the other is in a file and read into a variable. I use a string.Equals method to compare the contract IDs. The contract IDs compare successfully if the number in a contract ID is more than 1 away from the the other for example:

CTSRG0006 & CTSRG0005 = false

However

CTSRG0006 & CTSRG0007 = true

the code I am using for the comparison:

If fileContractID.Equals(calledContractID) Then
isFileValid = True
End If

View 1 Replies

VS 2005 - Only 1 Or 0 - ABS And EQUALS

Mar 29, 2010

I'm making a sort of VB.NET calculator that has all of the advanced features. I would also like it to have programming-style tips so that I won't have to build in things like ABS and EQUALS.

For example, ABS is sqrt(x ^ 2) and EQUALS is NOT(OZ(x-y)). NOT is 1 - OZ(x).
(x and y are the variables.)

I've come up with a few, but many rely on OZ(). OZ stands for 1/0. I need a formula that will return 1 if the value is <> 0, but 0 if it is equal to 0. I've worked on this for days but I can't come up with anything. Does anyone know how to do this?

View 39 Replies

What Is Different Between Equals And Referenceequals

Nov 8, 2009

i read it on internet article already, and tested it already. but it didnt show any difference.

View 3 Replies

.net - Using Two Equals Signs In VB 2008

Feb 6, 2012

In code, why wouldn't this work? intMax = intTopValue = 20

View 2 Replies

Difference Between Equals And = In LINQ?

Jun 10, 2010

What is the difference between Equals and = in LINQ?

Dim list As List(Of Foo) = (From a As Foo In FooList _
Join b As Bar In BarList _
On a.Something = b.Something _
Select a).ToList()

versus Dim list As List(Of Foo) = (From a As Foo In FooList _Join b As Bar In BarList _On a.Something Equals b.Something _Select a).ToList()

View 2 Replies

Equals Operator For Interfaces?

Dec 8, 2009

I have three classes which implement an Interface iComparesWith, and I wish there to be a single function such that each iComparesWith object of any of the three implementing classes should be able to compare itself with any other iComparesWith object, again, of any of the three implementing classes, and know if the two objects are equal. How can I code this so that the comparison code is only written once? Is it the case that I will have to create a top-level MustInherit class which implements the equality comparison, and have MustOverride methods for all of the methods of iComparesWith?

View 1 Replies

Overriding Equals For An Object With ID

Oct 11, 2011

Is it the best override for Equals (in VB.NET) for an object having an unique ID? [code]I took that example from the MSDN, but not entirely sure if from all points of view (including performance) is the better solution.[code]

View 2 Replies

Using Two Equals Signs In VB 2008?

Feb 13, 2011

In code, why wouldn't this work?

intMax = intTopValue = 20

View 1 Replies

Create A List Of Structures Within A List Of Structures?

Jul 20, 2009

I'm attempting to create a list of structures that contains a list of structures. I can't seem to figure out how to properly allocate the object for the inner list of structures. I expect the outer list of structures to have a couple thousand entries and the inner list of structures to be fairly small at 2 to 10. Both lists will grow over time but the number of elements within the inner list will be constant for an instance of the outer list. Meaning, if an instance of the outer list has 2000 entries each of those will have the same number of elements on the inner list, say 4 entries.

Here is a simplified code fragment. This fragment makes no attempt to create the instance of the inner list "StructBlist" since I can't figure out where to put it. Tried "New List(Of StructB)" in the declaration as well as "Alist(0).StructBlist = New List(Of StructB)" but neither works.

Public Class Form1
Structure StructA
Dim FieldA1 As Integer

[Code]....

View 5 Replies

C# - Use IEqualityComparer<T>.Equals() In ToLookUp<T>() Extension?

Aug 5, 2011

I stumbled upon an article regarding the Birthday Paradox and it's implications when overriding the GetHashCode method, I find myself in a bind.In tests, we found that in calls to the ToLookup() Extension, only GetHashcode is used, despite providing the implementation for Equals.

I think I understand why this happens, the internal working of ToLookup, HashSet, Dictionary, etc, use the HashCodes to store and/or index their elements?Is there a way to somehow provide the functionality so that the equality comparison is actual performed using the equals method? Or should I not be concerned with the collisions? I haven't done the maths myself, but according to the first article I linked, you would only need 77,163 elements in a list before reaching a 50% chance of collision.

If I understand this correctly, an Equals() override that compares property by property such as

Return (a.Property1 == b.Property1 && a.Property2 == b.Property2 && ...)

should have a zero chance of collision? So how can I get my ToLookup() to equality compare this way?

In case you need an example of what I mean:

[Code]...

I can get that to work with an override of GetHashcode(), no problems. But I don't want to use GetHashcode because if I have, for example, 109,125 elements in my list, apparently I'm already at 75% chance of collision? If it used aforementioned Equals() override, I think I'd be at 0%?

View 2 Replies

C# - Get The Number Of Rows Equals To A String In MS Reports?

Jan 13, 2012

Simple question but it is killing.

How do I write an expression, that return the number of rows where a column is equal something.

I can get the total rows like this: =Count(Fields!Foo.Value) and RowNumber("Rapporter")

But I can't get the number of rows where Foo is equal to someString

Foo is a type string.

View 1 Replies

Override 'Equals' In A Structure With All Shared Members?

Dec 5, 2011

I have a structure written in vb.net with all shared members. I need to override 'Equals', '==' and '!=' to avoid a warning.

View 4 Replies

String.equals() And Apostrophe - Execution Code ?

Oct 27, 2010

I just ran into what I consider a very strange issue in the execution of some code that I thought I had completely well-understood.

Basically, I was using this kind of notation:

If strOne.equals(strTwo) Then

rather than

If strOne = strTwo Then

I came from a c and java background, and using the '=' operator for comparison has always made me cringe, so I've used the .equals() comparison function thinking that it was equivalent. But just now some of my code broke. It encountered a string containing "Eagle's Nest: Dawn Patrol", used the .equals() to compare it to "Eagle's Nest: Dawn Patrol" and declared them not equal. I changed the code to use '=' rather than '.equals()' and it declared them equal. I also did this:

If strOne.Replace("'", "").Equals(strTwo.Replace("'", "")) Then

And again, it declared them equal.

This has me a little rattled because my code is filled with the use of .equals(), and I've used it assuming that it was no different than writing strOne = strTwo. I've scanned the interweb looking for information about this. I have not found any information about odd interactions between the apostrophe (or other) character(s) and .equals(). Microsoft's documentation does not hint at any subtle differences. how .equals() differs from '='

View 4 Replies

Use A Loop To Sum Until Cumulative Total Equals A Specified Figure?

Apr 29, 2010

I am trying to filter a dataset by adding together numbers within a specified field (say field1) within the dataset until i reach a specified number.

The filtered dataset should either be precisley equal to the number or most likley less than. In short if a row exceeds the number it should revert to the previous record.

I have no probs with general filtering and using data adapters to access the data. But im struggerling with the loop side of things.

View 4 Replies

VS 2008 Fill DataAdapter Parameter With 'CONTAINS' Instead Of 'EQUALS'

Nov 9, 2010

[code]Where I add my parameter, I am trying to have it pull records that contain the text that is in the jpDescTextBox instead of being exactly equal to it. I have tried using wildcards such as * and %.

View 7 Replies

Testing For Month Equals Zero With The Values Returned By An SQL Query?

Aug 3, 2011

I've got the hang of using dates now, but I haven't learned how to test multiple results of a query. I can return a value from a query, but I'm unsure how to return many without putting them into a data grid view or an object on the form. (In Visual Basic)I have to check when a particular investment needs to be bought or sold, there will be more than one in almost every case. I've got the function to find out the interval between the months, checking if the asset is bought or sold in month x, but I'm unsure how to test it against multiple assets at once - nor do I know the best way to do so.

View 12 Replies

.net - Why Have Equals Methods Have All Started Throwing Invalid Cast Exceptions

Mar 5, 2010

Several of my overriden Equals methods have started throwing Invalid Cast Exceptions -

Unable to cast object of type 'System.DBNull' to type Common.ResolveUser'.

This occurs when binding List (of T) (where T is of type ResolveUser in this case) to a combo.

Equals Method:

Public Overrides Function Equals(ByVal obj As Object) As Boolean
Dim i As ResolveUser = CType(obj, ResolveUser)
If i.UniqueResolveID = UniqueResolveID Then Return True

[Code]......

View 2 Replies

VB Coding - Program That Calculates Minutes Worked Times Pay Rate Equals Amount Of Weekly Pay

Mar 16, 2011

I am trying to build a program that calculates the minutes worked times pay rate equals amount of weekly pay this is what I got but it doesn't calculate

CODE:

View 3 Replies

Automating RDP Sign-in With VB

Jan 7, 2009

I want to use VB to set an existing RDP connection's credentials.Can I do that with code only?

View 3 Replies

Get The Sign Info?

Apr 28, 2011

I use the code below to get driver file sign info, it works well

Imports System.Security.Cryptography.X509Certificates
Dim cert As X509Certificate2 = New X509Certificate2("C:WindowsSystem32drivers cpip.sys")
MessageBox.Show(cert.Subject)

But if want to get EXE file signed info like

Dim cert As X509Certificate2 = New X509Certificate2("C:WindowsSystem32winlogon.exe")

MessageBox.Show(cert.Subject)

the error occured "Cannot find the requested object"

View 8 Replies

IDE :: Digitally Sign The Exe?

Apr 2, 2010

I want to digitally sign my exe. I have a .p12 file as digital certificate.I used signtool.exe for signing the exe. After signing the exe the properties > digital Signature tab is showing the right name but when I am doing double click on exe then the "open file-Security warning" window is still showing unknown publisher.How can I show right name of publisher in "open file-Security Warning" window.

View 1 Replies

IDE :: Do Not See DataTip Plus (+) Sign

Oct 5, 2010

I recently upgraded to VB 2010 Express (from 2008), and I have a problem using the debugger. When I move the mouse pointer over an array variable, I only can get the value for the current index, and not values for all indices, as I did in 2008.
For example, if I move the pointer to classSize(i), I see the value for the current value of index i, but I do not see the plus sign which would display a drop-down list showing values of all elements in the array.

I checked for options (Tools > Options > Debugging > General), but did not see an option related to DataTips.

View 6 Replies

.net - Using OpenSSL.net To Sign A Certificate?

Jul 31, 2011

I am trying to get OpenSSL.net to 1) create a key pair to use for CA signing and 2) create and sign certificates using this CA. I have managed to create an RSA/SHA1 X509CertificateAuthority, and have created a X509Request and keys, but I am running into problems actually signing the request.

'create the request and request key
Dim rsa As OpenSSL.Crypto.RSA = New OpenSSL.Crypto.RSA()
rsa.GenerateKeys(1024, 65569, Nothing, Nothing)

[code]....

I am getting an OpenSslException on the line noted above, with the message error:0606B06E:digital envelope routines:EVP_SignFinal:wrong public key type error:0D0C3006:asn1 encoding routines:ASN1_item_sign:EVP lib

View 1 Replies

Allow Only Numbers Backspace And - Sign?

Nov 28, 2009

I got this nice piece of code from someone on this forum which only allows user to input numbers or backspace i need to modify it to allow the - sign so user can input a negative number Can someone share with me the code to modify this

If Not Char.IsDigit(e.KeyChar) Then e.Handled = True
If e.KeyChar = Chr(8) Then e.Handled = False 'allow Backspace

View 2 Replies

C# - Single Sign On With 3 Applications

May 17, 2010

I'm building three web applications in .NET that will all share a users database and login information. Lets pretend that application 1 is the "parent" application and applications "A" and "B" are the "child" applications. All users have to be logged into application 1 to have access to applications A and B.

Authorization, Authentication, and MachineKey sections of all web configs are present and work correctly.

I have the correct web.config settings in all applications to achieve Single Sign On except one problem remains: what do I put in the "loginUrl" attribute of the forms tag in Applications A and B.

Assume that the url for the login to application 1 is [URL] How can I get applications A and B to send the user back to application 1 for authentication using only settings in web.config?

View 2 Replies







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