473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Option Strict On -help

I have an option strict on problem.

i am using the event for 1 button to be the event for several others, kind of like indexes in vb6.

it looks something like this:
*****
Private Sub btnNum0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNum0.Click, btnNum1.Click

if sender.tag = "1" then blah blah blah
*****

with strict off it works fine
with strict on it says "option strict on disallows late binding" with the squigly line under sender.text.

this was microsofts solution to trying to do "indexes" or arrays with controls for vb.net. is there a way to get this to work or a better way to reference the controls or get around the control array thing?

--------------------------------
From: carlin smith

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Eui8y8CctUyYqaxACNmI5g==</Id>
Nov 21 '05 #1
3 1644
Tag is an Object. You are comparing it to a string. That's why it doesn't
work.

Option Strict forces you to think about the types of your variables and
properties. If Tag was not assigned a string, this comparison would result
in an error. This way it is caught at run time.

"carlin smith via .NET 247" <an*******@dotnet247.com> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
I have an option strict on problem.

i am using the event for 1 button to be the event for several others, kind
of like indexes in vb6.

it looks something like this:
*****
Private Sub btnNum0_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNum0.Click, btnNum1.Click

if sender.tag = "1" then blah blah blah
*****

with strict off it works fine
with strict on it says "option strict on disallows late binding" with the
squigly line under sender.text.

this was microsofts solution to trying to do "indexes" or arrays with
controls for vb.net. is there a way to get this to work or a better way
to reference the controls or get around the control array thing?

--------------------------------
From: carlin smith

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Eui8y8CctUyYqaxACNmI5g==</Id>

Nov 21 '05 #2
"carlin smith via .NET 247" <an*******@dotnet247.com> schrieb:
I have an option strict on problem.

i am using the event for 1 button to be the event for several others, kind
of like indexes in vb6.

it looks something like this:
*****
Private Sub btnNum0_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNum0.Click, btnNum1.Click

if sender.tag = "1" then blah blah blah
*****

with strict off it works fine
with strict on it says "option strict on disallows late binding" with the
squigly line under sender.text.


\\\
Dim SourceControl As Control = DirectCast(sender, Control)
If SourceControl.Tag = "1" Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Carlin
if sender.tag = "1" then blah blah blah
if Directcast(sender,Control).tag.ToString = "1" then blah blah blah


Or much nicer

Select Case DirectCast(sender,Control).Tag
Case "1"
bla bla bla
Case "2"

Else

End Select

I hope this helps?

Cor
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: droope | last post by:
I have a routine that does a standard comparison that I pass two objects to Private Function ColumnEqual(ByVal A As Object, ByVal B As Object) As Boolea ' Compares two values to determine if...
9
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
8
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
6
by: Brett | last post by:
I find there is more casting required in C# than VB.NET. If Option Strict/Explicit is turned on, will this basically create the same environment as C# - uppercase, more casting required, must...
15
by: guy | last post by:
when i first started using .net (beta 1) i came across option strict and thought hey this could be really good, and since then have always turned it on, most people here seem to agree that this is...
13
by: C. Moya | last post by:
I fully expected the lack of a way to set Option Strict globally to be fixed in SP1. I can't seem to figure out if it has been fixed or not. It still seems we have to add the declaration at the top...
1
by: Jerad Rose | last post by:
I believe this issue is specific to ASP.NET. Why does VB.NET (2.0) ignore the project-level setting for Option Strict? I have the setting turned on in web.config: <compilation debug="true"...
18
by: Poldie | last post by:
How do I turn it on? I'm using vb 2005 in visual studio 2005 sp1. In my web.config I have: <compilation debug="true" strict="true" /> In my Tools/Options/Projects and solutions/vb defaults...
8
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the...
8
by: =?Utf-8?B?R3JlZw==?= | last post by:
We have an application in our office that has the Option Strict option set to off right now. I do understand it should be set to ON, but right now, I'm just going to continue with it this way since...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.