473,624 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(B yVal sender As System.Object, ByVal e As System.EventArg s) 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>Eui8y8CctUy YqaxACNmI5g==</Id>
Nov 21 '05 #1
3 1658
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*******@dotn et247.com> wrote in message
news:ew******** ******@TK2MSFTN GP10.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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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>Eui8y8CctUy YqaxACNmI5g==</Id>

Nov 21 '05 #2
"carlin smith via .NET 247" <an*******@dotn et247.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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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(send er, Control)
If SourceControl.T ag = "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(send er,Control).tag .ToString = "1" then blah blah blah


Or much nicer

Select Case DirectCast(send er,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
296
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 they are equal. Also compares DBNULL.Value If A Is DBNull.Value And B Is DBNull.Value Then Return True ' Both are DBNull.Value If A Is DBNull.Value Or B Is DBNull.Value Then Return False ' Only one is DBNull.Value Return A = B ...
9
2132
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 about Option Strict? What advantages do I get with Option Strict On? Does better type statement make my code run faster? If anyone knows THE ANSWERS! please fill me in. I have ideas and belief but I would once and for all like to know what the...
8
1823
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 record in a sql Server view) .... Dim entry As Domino.NotesViewEntry Dim obj As Object str1 = entry.ColumnValues(0)
6
1570
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 build event handlers? Thanks, Brett
15
1542
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 a good thing. i have now been asked to debug a vb2005 web app for 3 weeks and there is no mention of option strict in it, (there are also no classes defined, just a couple of structures) everything is define as 'as object', data coming back...
13
2314
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 of each and every single code module. Am I missing something here? -- -C. Moya www.cmoya.com
1
3132
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" strict="true" explicit="true" urlLinePragmas="true"/> And also in the preferences:
18
2880
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 I have option strict on. In my .vb file I have:
8
2418
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 man in question, in "Option Strict On" by default. Actually I don't believe I have code where this is not the case.
8
3883
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 I do not have the time to fix everything to set it to ON. Anyway, my question is if its set to OFF why is it it keeps getting set back to ON, everytime we move the package from one machine to another. It's the Option Strict option specific to...
0
8242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.