vb.net

Unit Testing of .NET Add-In for Microsoft Office

Has anyone got any suggestions for unit testing a Managed Application Add-In for Office? I'm using NUnit but I had the same issues with MSTest. The problem is that there is a .NET assembly loaded inside the Office application (in my case, Word) and I need a reference to that instance of the .NET assembly. I can't just instantiate the ...

Unable to close OledbDataReader to Sybase Database in VB.NET

I don't seem to be able to close the OledbDataReader object after reading data from it. Here is the relevant code - Dim conSyBase As New OleDb.OleDbConnection("Provider=Sybase.ASEOLEDBProvider.2;Server Name=xx.xx.xx.xx;Server Port Address=5000;Initial Catalog=xxxxxxxxxx;User ID=xxxxxxxx;Password=xxxxxxxxx;") conSyBase.Open() Dim cmdSy...

GridView Row to Object Type

In ASP.NET, if I databind a gridview with a array of objects lets say , how can I retrieve and use foo(index) when the user selects the row? i.e. dim fooArr() as foo; gv1.datasource = fooArr; gv1.databind(); On Row Select Private Sub gv1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArg...

looking for simulated annealing implementation in VB

Is anyone aware of a reasonably well documented example of simulated annealing in Visual Basic that I can examine and adapt? ...

Capture right-click'd text on Outlook Message Content

I'd like to know if it's possible to capture the text when a user right-click's on an Outlook message, and then add items to the right-click menu depending on the type of text. This is an example of what I'd like to do. If there's a message (mail item) with the following content: "Hello, please call me at 555-8474 regarding item A1234...

How do you call an Asynchronous Web Request in VB.NET?

I am currently using the following code to create a web request: Dim myRequest As WebRequest = WebRequest.Create("http://foo.com/bar") Dim myResponse As WebResponse = myRequest.GetResponse() The problem is that this "locks" up the program until the request is completed (and program will hang if the request never completes). How do yo...

.Net Data structures: ArrayList, List, HashTable, Dictionary, SortedList, SortedDictionary -- Speed, memory, and when to use each?

.Net has a lot of complex data structures. Unfortunately, some of them are quite similar and I'm not always sure when to use one and when to use another. Most of my C# and VB books talk about them to a certain extent, but never really go into any real detail. What's the difference between Array, ArrayList, List, Hashtable, Dictionary, S...

Problems adding a COM component reference to a VB.NET project

I have a third party COM dll that I'm trying to add to a vb.net (2008 express) project. I put the dll in C:\WINDOWS\system32\ and registered it with "regsvr32 vxncom.dll". When I go to projects > add reference and go to the COM tab it shows up in the list of available components/libraries. But, when I select the library and hit ok, visua...

What's the best way to generate a Text file in a .net website?

I have a page in my vb.net web application that needs to toss a bunch of data into a text file and then present it to the user for download. What's the best / most efficient way to build such a text file on a .net web server? Edit: to answer a question down below, this is going to be a download once and then throw-away kind of file. U...

What's the best way to instantiate a generic from its name?

Assuming I have only the class name of a generic as a string in the form of "MyCustomGenericCollection(of MyCustomObjectClass)" and don't know the assembly it comes from, what is the easiest way to create an instance of that object? If it helps, I know that the class implements IMyCustomInterface and is from an assembly loaded into the...

VB.NET - Application has encountered a user-defined breakpoint

I'm not that up on VB.NET, the application I'm working on was not written by myself. It works fine through the IDE but once I run it from the exe it gives me the above error. Any clues? This is really hacking me off! ...

object reference not set to an instance of object

I have been getting an error in VB.net "object reference not set to an instance of object". Can you tell me what are the causes of this error? thanks.. ...

Which language should I pick up: VB.Net or C#

I'm looking to pick up either C# or VB.Net. I'd done a fair bit of VB6 programming in the past. I'm looking at getting the book, Visual Basic .NET or C#, Which to Choose? but I'm hoping that someone has read it, or used both languages and can offer advice. Should I just RTFB? Edit: Anders Sandvig raised a valid question. I'm intend...

Best Practice: Potentially huge Winform grid?

Hi I am writing an application in VB.NET 2008 that manages software deployment and I want to display a "deployment overview" grid. The grid will be populated with the names of each application (top row) and the name of each workstation (1st column). The remaining cells will be populated according to whether the corresponding software t...

.NET Configuration (app.config/web.config/settings.settings)

I have a .NET application which has different configuration files for Debug and Release builds. E.g. the debug app.config file points to a development SQL Server which has debugging enabled and the release target points to the live SQL Server. There are also other settings, some of which are different in debug/release. I currently use t...

Do I have to use Viewstate in ASP.NET

I am moving from classic ASP to ASP.NET and have encountered what many of you already know as "viewstate". I might be jumping the gun with my assumption, but it looks highly cumbersome. I have developed many ASP forms in the past and never had issues with keeping state. Is there another way OR am I going to have to learn this Viewstat...

Programatically delete emails and SMSs on a Window Mobile device

Hello, I'm looking for a code snippet that can delete all emails and text messages on a Windows Mobile device. Preferably the code would delete items in the Sent and Drafts folders as well as the Inbox. My platform is Windows Mobile (5.0 SDK) and .net 2.0 compact framework (C# / VB.NET) Many thanks ...

Creating a multi-dimensional hashtable with generics in VB ASP.NET?

I need to create a multi-dimensional (nested) hashtable/dictionary so that I can use syntax like val = myHash("Key").("key") I know I need to use Generics but I can't figure out the correct syntax using VB in ASP.NET 2.0, there are plenty of c# examples on the net but they aren't helping much. Cheers! ...

Problem with datagridview and AddNew

I've created a VB 2008 program to track work requests. It all works perfectly on a VISTA box, but I am having an issue with the program on an XP environment with adding new records. Basically I've got 2 tabs: TAB 1 holds a datagridview with limited info and a calendar. Selecting dates on the calendar change the info in the datagridvi...

Create a method call in .NET based on a string value

Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName As String) Select Case reportName Case "Security" Me.ShowSecurityReport() Case "Configuration" Me.ShowConfigurationReport() Case "RoleUsers" Me.ShowRoleUsersReport() Case ...