Comparing Two Fields Without Knowing MemberType

Apr 4, 2011

Given the name of a field that exists on a class (public) and not knowing the field type, is it possible to compare this field on an instance of the class to the same field on another instance of the same class? I'm trying to do this for a "ValueHasChanged" function, something like the following:

Protected Function ValueHasChanged(ByVal fieldName as String) As Boolean
Dim presentFieldInfo = presentInstance.GetType().GetField(fieldName)
Dim originalFieldInfo = originalInstance.GetType().GetField(fieldName)
Return presentFieldInfo.GetValue(presentInstance) <> originalFieldInfo.GetValue(originalInstance)
End Function

The Return line spawns a compiler error about not being able to compare operands of type Object for operator '=', which makes sense, of course. Is there a way I can cast the values or do this differently without having to test the field's type and write a long switch/if...elseif statement?

View 2 Replies


ADVERTISEMENT

IDE :: Dual Check Program(check Duplication In Form By Comparing From Access Database Table Fields)?

Apr 9, 2010

Details: I want to compare these above two table1 and 2 . The unmatched records should be save in a new table .

objectives

1 Should take input the table and fields we want to match each other.

2 Then after searching or reading the record from table and selected fields save the unmatch records in a new table

View 1 Replies

Refactoring A Module Into A Class: Changing Shared Fields To Instance Fields

Nov 14, 2011

I'm currently refactoring an old Visual Basic DLL (VB.Net), which stores all of its data in one module called Globaldefinitions as public fields. There are about 200 fields, referenced thousands of times all around the code:

Public Module Globaldefinitons
Public a As Short
...
Public zz10 As Double

[Code]...

I need to change the module into a class with non-shared fields. This means, each and every of these thousands of references needs to reference the instance of that class:

globalDefinitionsInstance.a = 5

How do I go about this efficiently?

Regular expressions operating on the source fall flat. Refactoring tools like Re-Sharper or CodeRush don't seem to offer this functionality. Visual Studio 2010 cannot do it automatically either.

View 2 Replies

Can The Initialization Order Of Class Fields In .NET Be Influenced By References To Other Fields

Jun 19, 2011

Class Foo
ReadOnly name As String
Public Sub New(name As String, dependentUpon As Foo)
Me.name = name

[code]....

The output of New Bar() is:

Dependent created. Dependent upon nothing.
Independent created. Dependent upon nothing.

It seems fields are initialized in the same order as they appear in the source code, which (a) leads to an unexpected result, and (b) seems a little puzzling, given that one is normally not permitted to read from uninitialized variables in .NET, yet that seems to be working fine above.I would've expected VB.NET to be smart enough to initialize referenced fields first, and only then those that reference it; i.e. I'd have liked to see this output instead:

Independent created. Dependent upon nothing.
Dependent created. Dependent upon Independent.

how to get VB.NET to behave like that instead, without simply having to swap the declaration order of dependent and independent inside class Bar?

View 1 Replies

Create Word Form Fields With Memo Fields From Access?

May 27, 2012

I'm trying to create a table in Word using data from a table in Access. There are four fields in the access table that I need. 3 fields are text which I can populate the Word without any issues. However the fourth field is a memo with >255 characters.I'm struggling to come up with the proper code to allow me to populate the Word field with the memo data that has more than 255 characters. The code I have so far is listed below. But when it hits the memo field, it crashes on the line I marked with **. I know it's not text, but I've tried many different field types, but nothing has worked so far.[code]...

View 1 Replies

Validating Login Fields - Check The Username And Password Fields

Jan 14, 2012

My intent is to have the code - on a button.click event - check the Username and Password fields and return an error depending on which is wrong. Or if both are wrong, return a different error message. I've set the username as parts and the password as parts (still learning how to use external authentication). [Code]

View 2 Replies

Gridview Combine Autogenerated Fields And Template Fields

Aug 17, 2010

I have several sqldatasources for my gridview. All of the columns are autogenerated. However they all have some consistent fields and I'd like to make those fields template fields so I can modify the edit template for them such as adding a drop down menu. Is this possible?

View 1 Replies

How To Set A File Path Without Knowing If HDD Is C / D / E

Nov 19, 2010

I am a complete beginner and I was wondering where do I need to look to learn how to set a file path without knowing if the HDD is C:, D:, E:.. I'm using VB2010

View 5 Replies

Datatable Not Knowing Its Primary Key?

Mar 19, 2009

I'm trying to query a datatable to establish the primary key [identity column], by querying each columns autoincrement property. However its always false (for the column which is the Idenity/PK).

Querying the tables primary key collection reveals that the datatable doesn't think it has a PK.;

Dim dc As DataColumn() = dt.PrimaryKey
Debug.WriteLine(dc.Count) 'Result is 0

[Code]....

View 3 Replies

Knowing Who Is Online In ASP.NET Application?

Oct 16, 2009

how to display the list of all my application users who are currently online on a gridview and every user of my application sees who's online. How do I go about this if and if I am not using the built-in ASP.NET membership controls?

View 4 Replies

Retrieve The Key Of A Hasmap Knowing The Value?

Jun 14, 2011

How can i retrieve the key of a hasmap knowing the value?

Example:

'declaring
Dim myHash As New Hashtable
'filling it with some values

[Code]....

Now i want to retrieve the key, lets say of "Z", how i do it?

Did not fount any Method or property to do so.

Dim position as integer = myHash.Item("Z") ' do compile but not work always get position=0 when i expected position=1

View 5 Replies

C# - MS Word Office Automation - Filling Text Form Fields And Check Box Form Fields And Mail Merge

Sep 3, 2009

experience on how to create an engine using C# (VB.NET is okay too) that is generic enough to handle most cases of MS Word text fields I need to fill with data I'm getting from a database? In short, I'm about to embark on this little Office automation excursion and I'm hoping a little bit of feedback here.

View 2 Replies

Find Name By Knowing From Top Item Is Number 3

Jan 6, 2011

If I have four items in the listbox, e.g. a, b, c, d, how can I find the name by knowing from the top the item is number 3 (c)?

View 6 Replies

Access Directory Without Knowing Full Name?

Mar 10, 2010

I need to access Mozilla FireFox's cache, but the path to it is different in each PC. Well, kind of.

This is the path: C:Users%USERPROFILE%AppDataLocalMozillaFirefoxProfiles*.defaultCache"

The ".default" folder will always have that extension, but the asterisk part is different on each PC.[code]...

View 2 Replies

Find A File Without Knowing Where It Is On All Drives?

Aug 3, 2010

SPECS: Visual Basic 2008 - SP1/2, Framework 3.0.3.5, Windows XP Pro, SP3? trying to wright code for checking for existing files but what has me stumped is the (WHAT IF PART) of it witch in fact is what I want to see. What im saying is can I find a file without knowing where it is on all drives? Or how can i find a folder if I dont know where they installed it to.

Example: I know that C:Perfect World International <--- is the default location where my game installs but what if I installed it on D:Perfect World International; or rather on drive G or H. How would I test to see if it exist without making a bunch of nested If statements to test every drive for it.

this also applies to files like: D:Perfect World EntertainmentPerfect World Internationalelementelementclient.exe is there a way to find these files to see if they exist. I know that Perfect world international does not use the program files to put there program files in as you see above. so Envirnment variables I think cant be used correct me if I'm wrong. BUT I know the registry of a computer keeps some stord information as to where these applications are installed to like (References App Data).

What I'm trying to do is use this to tell the user in a Label that the game is installed in this path but I know in some circumstances the game is not installed on drive C: or D: or even in this directory some users can install it in there own directory such as C:PWI. and as such the file elementclient.exe can even be in C:PWIelementclient.exe. So to sum it all up can this be found useing some sort of code to find the file and folder and return them both in 2 difrent labels like this

Game Is Installed In: C:Perfect World International
Game Client Name: elementclient.exe, C:Perfect World Internationalelement
Game Found On Drive: C:
ETC.

I'm thinking and keep thinking that this can be done in many ways but as for environment variables I'm stumped. But perhaps windows registry may play a role in doing this but I myself don't even know where this stuff may be found; and even more how to apply it to code.

View 5 Replies

Hide A Window Knowing His Process ID?

Jan 10, 2006

How can I hide a window knowing his process ID?

I am writing a program which opens another application with the "shell" command (so it's easy for me to get the procID). Once it is running I want to hide or show it when needed by pressing a button in my program...

View 3 Replies

Knowing Document Inside Iframe

Jan 12, 2010

[code]Now ifrm.document will refer to the parent document.So what is the document INSIDE ifrm?

View 1 Replies

Knowing Scroll Location In The Windows

Jan 18, 2010

If document is big then there will be scroll bars in the windows. Does anyone know how to know the measurment of those scroll? For example, if I scroll to look at the bottom domain. Some topscroll or scrolltop property should go up. But which one?

View 2 Replies

Knowing What Input Radio Is Selected On ASP.NET (VB)

Jun 17, 2010

I'm creating input radio dynamicly on a ASP.NET page using PlacHolders.

While reader.Read
Dim ltr As New Literal()
Dim ltr1 As New Literal()

[Code]......

how can I get all the items selected on those input radio.

View 2 Replies

Moving A Picturebox Without Knowing Its Exact Name?

Feb 3, 2012

What happens to create the car is the user selects which car he/she wants to create from a combobox and then they press a button to create it.Private Sub btnCreateCar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateCar.Click

If cbCarSelect.Text.Contains("Ferrari") Then
c = 1
pictureboxesFerarri(c) = New PictureBox

[code]....

View 3 Replies

Resize A Window Knowing The Process ID?

Dec 17, 2008

I have an application that while running (it doesn't have to have focus, it can be minimized or another window can have focus) can listen and respond to global hot keys pressed. For instance I have the key combo Ctrl+Shift+0. When this hot key is pressed my app can recognize this and then I can do something.

This "something" that I want to do is:

1. Know what window is currently active and has focus when the hot key was pressed. And...

2. Change the size of said window

I can currently identify what window has focus by the following (the code block is inside the function that fires when the hot key is pressed):

Code:

Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByValhwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer

[Code]....

I can get the handle to the active window and the process that owns that window.

Having this information, how can I get access to the window itself? Furthermore, get access to it's properties so I can change the size of this thing? I'm not sure If this is the right information to be gathering for what I'm trying to accomplish but it seems that I'm close.

View 1 Replies

VS 2008 Accessing A DLL Library Without Knowing It?

Feb 22, 2011

Basically I am creating a Windows Service as an 'updater' program to update all my software packages. Whats going to happen is every piece of my software that is installed in its program folder will have an Update.dll this DLL will be a library to do with the update of the software.

There will also be a database in the Updater program folder which will contain a list of all my installed software. So when the service starts it will open my 'database' which will load the paths to all my installed software to a string array. Each path in the string array will have a Update.dll in the folder.

What I need to do then is is in turn call a routine called StartUpdate() from each of those Update.dll which will then do all the work. So the service itself is fairly basic and doesn't really do much I just need to figure out how to access DLL's when I don't actually know what ones will be there while programming, Reason I am doing it this way is to support my future software programmes without having to update the updater.

View 3 Replies

VS 2010 - Get Value Of Handle Without Knowing Type?

Dec 23, 2010

I am working on a new version of my clipboard manager. I was wondering if there would be a way to copy the value of a given handle without knowing its type? The current methods I know require one person to know the type of the handle (as an example by using Marshal.PtrToStructure).

View 1 Replies

Database - Compare Two Fields In An SQL SELECT Statement To Then Select Other Fields Based On This Result?

Apr 8, 2012

I have a table which contains a list of products for a company. They input data about how much stock they have and also the level at which they want to be reminded that they need to order new stock.

[Code]...

I want to list all the true results in a form which the user is then able to navigate through. What would be the best way to go about doing this?

View 2 Replies

Access To Window Properties Knowing Its Handle

Oct 10, 2009

I made a program that is started and running in memory and minimized to the system tray.

When it is first launched it registers global hot keys in windows.These hot keys are used for resizing the current focused window. I'm trying to use it so you can hotkey windows to resize to half the screen, a third of the screen, etc... For instance, if I have two notepads open and notepad 1 is focused and I hit Ctrl+Shift+LeftArrow it will resize notepad1 to the left and half the size of the screen. I have notepad 2 focused and Hit Ctrl+Shift+RightArrow and resize notepad2 to the right side of the screen. So, I can easily see both windows at once.Now, I can successfully get the focused window handle when the hot key is pressed. I'm stuck at this point.

I can use the Windows API call:

[code]...

View 4 Replies

Adding To Listview Inside Tab Control Without Knowing The Name

Sep 23, 2011

I have a tab control, that the user can add/remove tabs as they please. It is an inventory manager, and the tabs are the departments. Everytime a user adds a department, a new listview is cloned and added to the page. Upon form load, i need it to go through the tab pages, and query the database for items matching the department their in. In other words, if the Department column in the inventory database, matches the Tab Pages text, add it to the listview inside that particular page. I've tried several things, but they all end up buggy. Either it adds them all to the first listview, or it skips every other page, or worse - doesn't add anything at all. Here is the code I have, could anyone help me figure out how to:

Cycle through the pages, if any of the DB's rows Department column matches the tab page text, add it to the listview inside that tab page, then move to the next tab page, and cycle through the DB again. Here is my code, a decent start I believe.

Sub FillList()

Dim incs As Integer
Dim inc As Integer
Dim lst As ListView

[CODE]...

View 1 Replies

Any Way To Check If File Exists Only Knowing Extension?

Jan 8, 2010

Is there a way to find out if a file exists if you only have the file extension? I tried this but it doesn't seem to work.
If My.Computer.FileSystem.FileExists(drive.Name & "*.cde") Then

View 6 Replies

Change Variables In An Array Without Knowing Their Index

Jun 10, 2011

This may sound quite basic, but i was wondering how to change the value of a variable in an array, not knowing the index value but knowing what the variable is.

For example, I have an array and I want all strings within it that haven't got a value to say "Stretched". here is what i have tried:

For Each stl As String In Me.stl
If stl = "" Then
stl = "Centered"
End If
Next

My array is called stl(), and the size of it is always changing, so i can't just change the specific variables within the array

Also, is there some way to show/change etc all variables in an array? e.g. msgbox(stl(all))

I know this won't work, but what will?

View 4 Replies

Deployment :: Reliable Way Of Knowing Number Of Downloads

Jan 20, 2012

I eyed VB.NET 2010 Express and created the damn app. It's up and running and it does what it's supposed to do (in v1). Now I'd like to distribute it for free while:

(1). Have a reliable way of knowing (and everybody can check this out) the number of downloads.

(2). The app cannot be passed from one user to another, but has to be downloaded from the reputable biz (there can be more than one biz) that accurately provides the number of downloads.

(3). I can have total control over the app (once it's downloaded by the users), that is if I want to inform the users of updates or whatever, or if I want to add some ad windows to the form I can do it whenever I want and how I please.

How do I do (1) to (3)? What am I supposed to read to do (3)? ADO.NET and ASP.NET? Any shortcut? What's the easiest way of doing it? I'm not sure I'm looking for a career in programming, for now I just want to take this app off my shoulders and go back to daydreaming.

View 4 Replies

Get The Dimensions Of A Characters Knowing All The Details On The Font

Sep 7, 2011

I need to create bitmaps of characters depending on a specified font. When they specify a font, they are specifying:

[Code]....

Knowing this, is it possible to determine the size that a character will be exactly if I know the character and all the information above? I have to draw them to bitmaps that are the same size as the character and no bigger.

View 1 Replies







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