vb.net

GUI to Business Object Mapping VB.Net

The issue I'm currently having is mapping multiple GUI fields to object properties (i.e. Presentation layer to Business Logic Layer mapping). To be more specific, this is in VB.Net 2.0 WinForms. The nature of the solution requires us to have 4 columns which exhibit the same type of behavior on our GUI - each column consisting of 11 tex...

How to break dependencies without modifying production code?

From my initial readings on unit testing (I'm a beginner) it is wise to put all of your setups and tests in a separate project from the code being tested. This seems ideal to me, as well. However, I've recently begun reading The Art of Unit Testing, trying to discover how to break dependencies on things such as database calls. The met...

select case to check range of a decimal number

i need to check whether a demical is 0 through 49.99 or 50 through 99.99 or 100 through 199.99 or greater than 200. i am trying to do this with select case, but i am not sure of the syntax. please help! ...

converting to double (error)

i am converting a string to double i would like to know in advanced whether it would case an error to convert a string to a double. for example if i try to convert "hello" to a double, it would give me an error. is there a way for me to know ahead of time whether converting something will cause an error? ...

DataGridView in VB.net will not allow me to update

I have a datagridview with a dataTable as the dataSource. The user can add new rows to the datadridview, but I dont display the primary key column (for obvious reasons) and set it to .visible = false. When I need to update the information in the datagridview to the database, I use the sqlClient.SqlCommandBuilder to then update the underl...

checking if a string is a double

If Double.Parse(list_numbers.Item(i), possibledouble) list_numbers is a list of strings list_numbers.Item(i) = "0.000" possibledouble is a double debugger returns "input string was not in a correct format" i thought that the double parse would convert the string into a double format of "0.0" but it gives me an error. please help ...

Is there a way to compare Date objects ignoring the time?

Is there a way to compare two dates (which include time) ignoring the time? I have a 1/1/2009 8:00am and 1/1/2009 9:00am and I just want to know if it is the same day, without any care to what time it is. I know I can convert the date and compare the strings, but is there another way? ...

Search website page content in VB.NET - 3rd party tools? Code Examples?

I am hoping to implement search in my asp.net website. I have been searching the web, but I am not sure which way to go. Here is what I am looking for: ability to search the text in static pages on my site exclude pages or folders that I don't want to search code must be in vb.net or c# must be something I can quickly implement .net 2....

Checkboxes not updating as expected

I have a listbox bound to a list of business objects. The items in the listbox are formatted using an itemtemplate. The itemtemplate includes a checkbox bound to a boolean property of the business object. When I spin up the app, the bool prop on the object in the list is changed when I click the checkbox. so far, so good. The dialog has...

How data sources are linked in compiled Visual Basic .NET applications?

When I try adding a new data source to my project I get a prompt saying "The connection you selected uses a local data file that is not part of the current project. Would you like to copy the file to your project and modify the connection?" This sounds rather obscure to me, as I'm new to VB.NET and programming non-script apps in general...

Query Notation for Select overload with index ...

There is a Select overload that adds an index to each element of a sequence : Dim Letters = new string() {"a","b","c","d","e"} Dim IndexedLetters = Letters.Select(function (aLetter, index) new with {.Index = index + 1, .Letter = aLetter}) ' For LINQPad users : IndexedLetters.Dump Can this query be written in Query Notation ? ...

Send KeyEvent from a Form to a Control

I have a Windows.Worms application. In one of my forms I display a DataGridView with a ContextMenu (not ContextMenuStrip) associated to it. The MenuItems in the ContextMenu have Shortcuts defined. This is how the ContextMenu is created: Private _contextMenu As _ New ContextMenu( _ New MenuItem() { _ ...

.NET Different References List for Debug / Release

In my debug build I have a reference to a DLL that is only required in the Debug configuration (the reference is for CodeSite, a logging tool). Is it possible to exclude this reference in the Release build (my logging class only uses this reference when built in the Debug configuration). Using VB.NET and VS2008. ...

Determine if an event has been attached to yet

I have two objects - one that contains some code with will fire an event, and one that contains the handler for that event. I can't "AddHandler" in the Load of the first object, because an instance of the second object doesn't exist yet. When I raise my event, I want to check to see if a copy of object2 has been instantiated (easy to do)...

Can't create HtmlHelper methods in VB MVC app

I can't figure out what I'm missing in the following code. I've got a method that should add a (dummy) helper extension: Imports System.Runtime.CompilerServices Namespace HtmlHelpers Public Module HelpExtensions <Extension()> _ Public Function HelpMe(ByVal HtmlHelper As HtmlHelper) As String Return "<a...

Emulate Excel Web Query in .net

I need to emulate an Excel Web Query in .net Below is the sample code. I get an Error500 when I attempt to do this in .net, however in Excel it works fine. Any ideas on what I am doing wrong? When I change the URI to a normal website it works fine, and returns the html from the page, which i what i am after. I wonder if the problem lies ...

Binding arraylist to grid view (Part whatever....)

Ok, I'me getting real dumb with this one.... I have this class: Public Class whatever Public id as string Public name as string public date as string end class Wich I use with this code: dim personlist as new arraylist dim person as new whatever person.id="1" person.name="bozo" person.date="6-6-6" personlist.add(person) and then ...

Interaction between two user controls

I'm on the verge of madness ... In the application I'm actually building, I'm dealing with two dynamically-added controls that need to interact with each other, but I've reduced the problem to an as-simple-as-I-can-make-it example with the controls being statically loaded, and it still presents the same problem: a NullReferenceException...

Valid filename check. What is the best way?

See subject of positing for question. 1) I recall seeing a really cool option in VB.NET using LINQ to match using "LIKE%' 2) I know regular expressions will work and I suspect that will result in the shortest code and probably won't be too hard to read for such a simple test. Here's what I did. Warning: You're gonna hate it. Private ...

Detecting user presence

What I would like to do is detect if a user is actively using a computer running Windows (2000 or later). Preferably, I would like to do this without resorting to using screensavers. Background: We have a customer service department that sits in a hunt group and can be "Available" or not. If they are "Available" calls will be routed t...