Questions tagged [option-strict]

The Option Strict Statement restricts implicit data type conversions to only widening conversions which disallows late binding, and also disallows implicit typing which results in an Object type.

Option Strict turns on strong type checking in the Visual Basic .NET programming language.

50 questions
0
votes
1 answer

Dealing with error message narrowing from type object to type string

I am getting this error message when converting code from .Net 2.0 to .Net 4.5: Option strict on disallows narrowing from type 'object' to type 'string' in copying the value of 'ByRef' parameter 'ParamValue' back to the matching argument. The…
Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125
0
votes
1 answer

Option Strict appears to be considered as on despite being off since last Visual Studio Update

Since last week's update of my Visual Studio all my projects are coming up with errors such as "Option Strict On requires that all method parameters have an 'As' clause" despite the project having the Option Strict "Off". It's happening on all my…
Corobori
  • 303
  • 3
  • 13
0
votes
1 answer

Dim declaration with assignment and Option Strict

I have run into an issue with my code, as follows: Option Explicit Off Option Strict On 'Results in Compiler Error. Expected base or compare or explicit or private Sub DoSomething() Dim intOne As Integer 'This line works intOne = 1…
0
votes
1 answer

Enforce datatypes passed to methods (Option Strict)

I am using VS2005 to maintain some vb.net code. I am preparing to update to newer toolsets and am doing code cleanup first. I am cleaning up all the compile error messages, but I noticed that I do not get a warning if I pass a String to a function…
Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125
0
votes
0 answers

Why does WAP Web Forms project fail to compile with no code changes?

In Visual Studio 2013, I created a new project via File > New Project > Installed.Templates.Visual Basic.Web.ASP.NET Web Application, and then selected the Web Forms suboption. Without doing anything at all to the code - no additions, no…
0
votes
1 answer

Late Binding Vb .Net

Trying to set my labels text to = the value of a specific row & columns value. I prefer to use Option Strict On but its disallowing the late binding. Ideas? Private Sub BuildText(ByVal dtData As DataTable) Try lblVendor.Text =…
Holmes
  • 21
  • 5
0
votes
1 answer

vb.net option strict disallows late binding when trying to add to array cant turn off

I am trying to build my combobox with items from my array, but am getting this error: Here is my code: Private Sub frmInventory_Load(sender As Object, e As EventArgs) Handles Me.Load Dim InvArray As Array InvArray =…
John
  • 55
  • 5
0
votes
1 answer

Extension methods declared on Object need one more parameter than others?

Extension methods on Object can be declared on Object but cannot be used like obj.ExtMethod(). This is by design. On the other hand, any extension method can be also used like ExtMethod(obj). Why calling of extension methods declared on Object…
miroxlav
  • 11,796
  • 5
  • 58
  • 99
0
votes
1 answer

WPF DataGridRow.Item("xx") - Option Strict On disallows late binding

WPF application using DataGrid. User double-clicks on a cell, and I need to get the value of another cell in that row. Dim dep As DependencyObject = DirectCast(e.OriginalSource, DependencyObject) Dim dgRow As DataGridRow = Nothing While dep IsNot…
tolsen64
  • 881
  • 1
  • 9
  • 22
0
votes
0 answers

Is there a way to use EventManager and still keep Option Strict On

Using Wpf and MVVM. I have a main window in which I happen to have an Actipro Docksite (although I believe for the overall context of this question that is probably irrelevant). The docksite has a WindowClosing event which I wish to handle but in…
Dom Sinclair
  • 2,458
  • 1
  • 30
  • 47
0
votes
1 answer

Option Strict On disallows implicit conversions from 'System.Drawing.Point' to 'System.Drawing.Size'

After i tried to optimize my code with option Strict ON i get many errors at least one is left. i've created the Variable MoveForm_MousePosition as Point = System.drawing.point Imports System.Drawing Public MoveForm_MousePosition As…
0
votes
0 answers

Invalid Cast Exception On One Machine Given Same Assembly & Data

I have encountered an unusual situation where the same code is behaving differently on a particular machine. The program is written in VB.NET and WF4. The workflow XAML is read from a database at runtime and compiled on the fly. I mention this only…
0
votes
1 answer

FileHelpers Master/Detail - Option Strict On disallows late binding

I am having some problems to determine how can i remove the errors i am having using FileHelpers with the option strict on. I initialized the class MasterDetails Private _res As MasterDetails() The function to call the MasterDetailEngine Private…
Filipe Costa
  • 655
  • 3
  • 13
  • 30
0
votes
1 answer

Read from txt file and using Public Function

Hey everyone i have some code here that bring in one line text from a file and displays into labels. I want to add up eight values from labels and divide by 8 to get the average, and convert that average score into a letter grade that will be…
king_sw4
  • 1,125
  • 2
  • 11
  • 18
0
votes
2 answers

Limiting strict off VB.NET

Hi I am exploring ways to implement something Visitor Patterns alike without all the decorating visit methods. Sofar I found out I could use Option Strict Off in VB.NET but it has some side effects. I have a set of Shape classes that inherit from a…