vb.net

Using strings in XML Literals

Hi, I'm a C# developer who's fumbling in the first VB code he's written since VB6, so if I am asking a rather obvious question, please forgive me. I decided to experiment with XML Literals to generate some XML code for me, instead of using XMLDocument I have 2 questions, the second regarding a workaround due to my inability to figure ...

Updating Legacy Code from System.Web.Mail to System.Net.Mail in Visual Studio 2005: Problems sending E-Mail

Using the obsolete System.Web.Mail sending email works fine, here's the code snippet: Public Shared Sub send(ByVal recipent As String, ByVal from As String, ByVal subject As String, ByVal body As String) Try Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage Message.To = recipen...

ASP.Net word count with a custom validator

A requirement for an ASP.Net 2.0 project I'm working on limits a certain field to a max of 10 words (not characters). I'm currently using a CustomValidator control with the following ServerValidate method: Protected Sub TenWordsTextBoxValidator_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidate...

Does anyone know a library for working with quantity/unit of measure pairs?

I would like to be able to do such things as var m1 = new UnitOfMeasureQuantityPair(123.00, UnitOfMeasure.Pounds); var m2 = new UnitOfMeasureQuantityPair(123.00, UnitOfMeasure.Liters); m1.ToKilograms(); m2.ToPounds(new Density(7.0, DensityType.PoundsPerGallon); If there isn't something like this already, anybody interested in doing i...

Should I always use the AndAlso and OrElse operators?

Is there ever a circumstance in which I would not want to use the AndAlso operator rather than the And operator? or in which I would not want to use the OrElse operator rather than the Or operator? ...

Starting a new job focused on brownfield application refactoring & Agile

I am starting a new job on Monday. The company has a home grown enterprise case management application written in ASP.NET/VB.NET. They are attempting to implement an Agile development process. They have gone so far as to get two people Scrum Master certified and hire an Agile coach. They are currently focused on 6-9 months of refactoring...

UI Thread Safety

Any suggestions on the best way to ensure thread safety when changing the properties on Form controls? I have been using Me.Invoke in the past, and I was wondering if you have pros/cons, comments, suggestions, etc. ...

Opening a file stored in a database in .NET

I'm storing a Word document in a SQL Server 2005 database in a varbinary(max) column. Is there a way to open this document from a VB.NET Windows Forms application without serialising to a file first (i.e. directly from the byte array I've read from the database)? ...

ToolStrips in TabPages frequently disappear from Windows Forms designer

I have a Windows Form app with a TabControl. One of the TabPages in the TabControl contains a ToolStrip. Frequently, the Windows Form designer will spontaneously set the Visible property of the Toolstrip to False. To get the toolstrip to reappear in my form, I have to manually find the control and set the property back to True. It's real...

Upgrading from .NET 1.1 to .NET 2.0, what to expect?

I'm working on a big .NET 1.1 project, and there exists a wish to upgrade this, majorily to be able to use better tools like Visual Studio 2008, but also because of the new features and smaller amount of bugs in the .NET 2.0 framework. The project consist for the bigger part of VB.NET, but there are also parts in C#. It is a Windows For...

Converting vb.net to c# tips

I am using reflector disassembly as a quick way to convert some vb.net to c# and am hitting some problems with certain VB-isms: Conversions Strings Information.IsNothing When trying to compile the converted code, I need to find and change all of these and more. Any tips on converting vb.net to C# in a clean way? ...

.NET Date Const (with Globalization)

Does anyone know of a way to declare a date constant that is compatible with international dates? Ive tried: public const ADate as Date = #12/31/04# - not international compatible public shared readonly ADate As New Date(12, 31, 04) - breaking change if you have an optional parameter that defaults to this value because it isnt constant...

Handles vs. AddHandler

Is there an advantage to dynamically attaching/detaching event handlers? Would manually detaching handlers help ensure that there isn't a reference remaining to a disposed object? ...

Best way to send an email from a .NET application?

I'm working on a Windows Forms (.NET 3.5) application that has a built-in exception handler to catch any (heaven forbid) exceptions that may arrise. I'd like the exception handler to be able to prompt the user to click a "Send Error Report" button, which would then cause the app to send an email to my FogBugz email address. What's the b...

What exactly is "managed" code?

I've been writing C / C++ code for almost twenty years, and I know perl, python, php, and some java as well, and I'm teaching myself javascript. But I've never done any .NET, VB, or C# stuff. What exactly does "managed" code mean? Wikipedia describes it simply as "code that executes under the management of a virtual machine", and it spec...

Combining Enums

Is there a way to combine Enums in VB.net? ...

Should I learn C# or Java?

Guys, I'm good with VB.Net, I don't see why I should officially learn C#, instead I want to learn Java so I can develop for different platforms. What is your advice? ...

How do I toggle Caps Lock in VB.NET?

Using VB.NET, how do I toggle the state of Caps Lock? ...

How do I get the current state of Caps Lock in VB.NET?

How do I find out whether or not Caps Lock is activated, using VB.NET? This is a follow-up to my earlier question. ...

Easiest way to add a Header and Footer to a Printing.PrintDocument (.Net 2.0)?

What's the easiest way to add a header and footer to a .Net PrintDocument object, either pragmatically or at design-time? Specifically I'm trying to print a 3rd party grid control (Infragistics GridEx v4.3), which takes a PrintDocument object and draws itself into it. The resulting page just contains the grid and it's contents - howeve...