option-strict

What is the best way to mix VB.NET's Option Strict and the new Option Infer directives?

In a related question, my team is about to (hopefully) start using LINQ, and I'd like to take advantage of anonymous types. What is the best way to mix VB.NET's Option Strict (which we've been using through the life of the project) and the new Option Infer directives? ...

Converting enum tostring of underlying type in VB.Net (Option Strict On)

I'd like to get a string representation of the underlying type of the enum. Dim target As System.ConsoleColor = ConsoleColor.Cyan Dim actual = 'What goes here? Dim expected = "11" ...

VB.NET Turning Option Strict Off In-Line

Is there a way to turn option strict off for just a single line of code? I'm doing some maintenance work and I need to "cheat" in just one place and I don't want to lower the standard for the entire file. ...

Using early binding on a COM object

Hello, I have this piece of code that works very well and gives me the path the user's start menu: Dim oShell As Object = CreateObject("Shell.Application") MsgBox(oShell.NameSpace(11).Self.Path) This obviously uses late binding. Now say I want to do this in C#, or in VB.NET strict mode, neither of which support this kind of s...

linking to options drop down

I don't know if this is possible so bare with me on this one. Can you link to a specific value in an options drop down box from another page? In other words, let's say that I'm on page 1 and I want to anchor link to page 2 that has an options drop down box with 3 different values in it. Let say by default when you go to page 2, the drop ...

Do you use strict off in your projects?

Do you use 'strict off' option, 'explicit off'? Or may be 'strict custom' and some other options like 'Implicit type. Object assumed', 'Late binding', 'Implicit conversion'? ...

Linq query has an implicit cast error for DataGridViewRow when option strict is enabled

I have a DataGridView that is bound to a list of objects called "BaseChange". The BaseChange objects are made up of 4 properties... ChangeType ChangeStatus ChangeDescription LastChangeDate The datagridview has columns for all 4 values as well as a 5th (a checkbox column called "colIsSelected"). There is no problem binding the list to...

Tools to convert option strict off code into option strict on?

I have to take over a project written in vb.net, which contains more than 400k lines of code written in option strict off mode. I want to build it under option strict on first before I do anything else -- which maybe converting it into C#. I found there's thousands of lines of code raises compilation error, mostly are about implicit type...

VB.Net equivalent for C# 'dynamic' with Option Strict On

Is there an equivalent for the C# 4 'dynamic' keyword when using 'type safe VB.Net', i.e. with Option Strict On? ...

Why does the compiler think this is an Object instead of a DataRow?

I'm using a LINQ query to translate data inside a DataTable object to be a simple IEnumerable of a custom POCO object. My LINQ query is: Dim dtMessages As DataTable '...dtMessages is instantiated ByRef in a helper data access routine... ' Dim qry = From dr As DataRow In dtMessages.Rows Select New OutboxMsg...

VB.NET: Which As clause to use with anonymous type with Option Strict On?

Consider the requirement to always declare Option Strict On. We'll always need to declare variables with the As keyword. What would be the type of an anonymous type? Example : Dim product As ... = New With { Key .Name = "paperclips", .Price = 1.29 } What will follow the As? ...