vb.net

Format Text from a Textbox as a Percent

I have a numeric value in a Textbox that I'd like to format as a percent. How can I do this in C# or VB.NET? ...

Anonymous class initialization in VB.Net

i want to create an anonymous class in vb.net exactly like this: var data = new { total = totalPages, page = page, records = totalRecords, rows = new[]{ new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}}, new {id = 2,...

IList(Of T).Sort help

Dim classCodeDetails As List(Of ClassCodeDetail) = db.ClassCodeHeaders.Single(Function(cch) cch.CLCH_ID = classCodeHeaderId ).ClassCodeDetails.ToList() classCodeDetails.Sort(Function(c1, c2) c1.Make.MAKE_English.CompareTo(c2.Make.MAKE_English) ) My question is how can I sort on multiple attributes? I want to...

VB.NET service Shutdown

I have a VB.NET Windows Service that I wrote and it works fine. In VB.NET there is an overrideable method called OnStop() that gets called when the service is stopped. However, it appears it only gets stopped if someone actually stops the service from the Services MMC Console Window. My question is, is there an event or an overridable m...

ListView ItemActivate Delay

I have a ListView with the Activation property with HotTracking. There appears to be about a 2 second delay between when the user clicks the item and the event fires. Is there a way to get the event to fire immediately upon the user click? ...

What's the best way to change the namespace of a highly referenced class?

I am attempting to move a highly referenced class from one namespace to another. Simply moving the file into the new project which has a different root namespace results in over 1100 errors throughout my solution. Some references to the class involve fully qualified namescape referencing and others involve the importing of the namespace...

Efficient way to check if DataTable has row

Hi, I have a function that search for a keyword and then return DataTable. I want to check if there rows inside because sometimes there's no query found. 'which one shoud I use ? If dtDataTable Is Nothing Then 'some code lbl_count.Text = "Found 0 result" End If If dtDataTable.Rows.Count > 0 Then ...

Handling VB.NET events in VB6 code

I have some VB6 code that instantiates a class which handles events that are being raised from a VB.NET component. The VB6 is pretty straightforward: private m_eventHandler as new Collection ... public sub InitSomething() dim handler as EventHandler set handler = new EventHandler m_eventHandler.Add handler ... m_engine.Star...

VSTO CommandBarButton position

I'm writing a VSTO add-in to add a button the Standard toolbar for all new MailItems in Outlook 2003. I've got it mostly finished, but I can't see to work out how to set the button's position on the taskbar - ideally I'd like to place it right next to the Send button. Here's the code I have so far. Private Sub colInsp_NewInspector(By...

Updating access error.

Dim conn As OleDbConnection Dim cmd As OleDbCommand Public Sub openDB() conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\VFMS_DB.mdb;" & "Jet OLEDB:System Database=Security.mdw;User ID=Adster;Password=300624;") conn.Open() End Sub Public Functio...

Parse a string to an Enum value in VB.NET

Hi guys, How can I parse a string in VB.NET to enum value? Example I have this enum: Public Enum Gender NotDefined Male Female End Enum how can I convert a string "Male" to the Gender enum's Male value? ...

VB.NET Parsing an Object type to a GUID type.

Hi guys... how can I convert an object type to a GUID type in VB.NET? ...

Pulling database information from gridviews that is not displayed on the gridview

I've created a Gridview control that pulls some data from my database, but doesn't display all of the information I'm hoping it gathers. I choose not to display the primary key for user interface purposes, but require that key for basic operations on the grid. I'm currently attempting to add a "Delete" option to the table, but unfort...

Executing Sql statements with Fluent NHibernate

Basically I want to be able to do this: session.ExecuteSql("..."); I don't need it to map to any entities or return any values. Any suggestions? ...

Using Lambda in Unit Test in VB.NET 2008 with Rhino.Mocks

Hi, I am trying to create a unit test similar to how I would have done one in C# but am struggling with the lambdas in vb. Bascially I am trying to mock a class and then create a stub and return. In C# I would have done something like; MockedPersonRepository .Stub(x => x.Find(id)) .Return(person) But in visual basic I am t...

merged cell's contents cut off beyond page break

I have a vb .net program that exports information to certain fields of an excel workbook using named ranges. One of the named ranges is a notes section that gets cut off (not visible nor gets printed) if it extends beyond a page break. I am looking for a way to dynamically create new named ranges to accommodate all of the notes' text. S...

Compiler randomly catching and not catching the same bug over and over. 'DataKeys' is not a member of 'gridView'.

First of all, I'm using VS2005. On random compiles, I'll get the following error: 'DataKeys' is not a member of 'gridView'. This makes no sense to me, since DataKeys is obviously a member of GridView. Intellisense thinks so, the internet thinks so, I think so. The line that's causing this issue is... Dim myGridView As GridView = CTy...

Visual Studio "Start Debugging" vs. "Attach to Process"

I have a client/server application using the .Net 2.0 Framework. I'm using Visual Studio 2008 to build and manage code. When I run either a Debug or Release version of the application simply by starting the .exe, I get an insert statement on the database that tries to insert a "0" for the foreign key of a table, triggering an error beca...

How to cancel an ASP.NET MVC action

This should be simple, but the answer is eluding me. If I've got a Save action in my controller, and the save fails, how do I cancel the action without disturbing what the user entered? For example, Index is strongly-typed of "MyTable": Function Index() As ActionResult ViewData("message") = "Hello" Return View(New MyTable) End F...

Mini Web Server for .NET

I wrote a VB.NET windows service and I'd like to know if there is some library or something that will provide me with a very simple mini web server. If my service is running, I'd just like to be able to type, in my browser: http://localhost:1234 And have a status page popup. It will only be one single page and very simple html. Anyone ...