This code worked before I added option strict. But I should do it correctly.
option ...
option Strict On
Public Structure Itm
Dim mailSvr As String
...
Public Sub New(ByVal a1 As String...)
mailSvr = a1
End Sub
End Structure
Sub...
ht = New Hashtable
ht.Add("0", New Itm("thecorporatecounsel", ".net", "CC", "TCCNET_ID", "T"))
ht.Add("0", New Itm("thecorporatecounsel", ".net", "CC", "TCCNET_ID", "T"))
....
End Sub
Sub ...
str1 = ht(0).mailSvr <<<<----complains here now - say late binding not
allowed
....
End Sub
What do I need to do to make it early binding? What do I need to cast this
to?
Any suggestions appreciated.
Thanks,
Rich 3 1059
The index 0 is actually a string "0". Still complains though with option
Strict on
Sub ...
str1 = ht("0").mailSvr <<<<----complains here now - say late binding not
allowed
....
End Sub
I tried CType(ht("0").MailSvr, String) ---- still complains
wait !!!! I just tried this and it stopped complaining !!!
str1 = CType(ht("0"), Itm).mailSvr
Nevermind. He's happy again.
"Rich" <Ri**@discussions.microsoft.com> schrieb This code worked before I added option strict. But I should do it correctly.
option ... option Strict On
Public Structure Itm Dim mailSvr As String ... Public Sub New(ByVal a1 As String...) mailSvr = a1 End Sub End Structure
Sub... ht = New Hashtable ht.Add("0", New Itm("thecorporatecounsel", ".net", "CC", "TCCNET_ID", "T")) ht.Add("0", New Itm("thecorporatecounsel", ".net", "CC", "TCCNET_ID", "T")) ... End Sub
Sub ... str1 = ht(0).mailSvr <<<<----complains here now - say late binding not allowed ... End Sub
What do I need to do to make it early binding?
Cast to the type of the object.
What do I need to cast this to?
To type Itm:
str1 = directcast(ht(0), Itm).mailSvr
If you will access the hashtable in more situations, you should consider
writing your own collection having a typed Item property.
Armin
"Rich" <Ri**@discussions.microsoft.com> schrieb: This code worked before I added option strict. But I should do it correctly. [...] Public Structure Itm Dim mailSvr As String ... Public Sub New(ByVal a1 As String...) mailSvr = a1 End Sub End Structure
Sub... ht = New Hashtable ht.Add("0", New Itm("thecorporatecounsel", ".net", "CC", "TCCNET_ID", "T")) ht.Add("0", New Itm("thecorporatecounsel", ".net", "CC", "TCCNET_ID", "T")) ... End Sub
Sub ... str1 = ht(0).mailSvr <<<<----complains here now - say late binding not
Use 'str1 = DirectCast(ht(0), Itm).mailSvr' instead. In .NET 2.0 you can
use one of the generic dictionary classes which can be parameterized with
the item type instead of 'Hashtable'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: noone |
last post by:
I like to write my code with optionstrict set to on, except for the late
binding errors I get when there is a reason to change some value in a
control on a postback, like:
Label4.Text =...
|
by: Karl Lang |
last post by:
Hi
I've created a new configuration section in Web.Config to hold the
connection string for my database. If I have Option Strict On I get a
message "Option Strict On disallows late binding" when I...
|
by: Dieter Schwerdtfeger via DotNetMonster.com |
last post by:
I have this function where i search through my database for items that were made on a specific date. The line "CType(dvClubs.Item(teller).Item(veld).ToShortDateString" gives me the error : option...
|
by: eBob.com |
last post by:
In another thread VJ made me aware of Tag. Fantastic! I've been
wanting this capability for a long time. But it seems that I cannot
use it with Option Strict On. In an event handler I have ......
|
by: lgbjr |
last post by:
hi All,
I've decided to use Options Strict ON in one of my apps and now I'm trying
to fix a late binding issue. I have 5 integer arrays:
dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
|
by: David |
last post by:
Hi all,
I have the following problem: my program works fine, but when I add option
strict at the top of the form, the following sub fails with an error that option
strict does not allow late...
|
by: Heinz |
last post by:
Hi all,
I use VB.net 2003 and want to export data to Excel. Target PCs still
have Office 2000 so I could not use Microsofts PIAs. Instead I use the
included Excel 10 COM DLL from Microsoft....
|
by: Tim Roberts |
last post by:
I've been doing COM a long time, but I've just come across a behavior
with late binding that surprises me. VB and VBS are not my normal
milieux, so I'm hoping someone can point me to a document...
|
by: Rippo |
last post by:
Hi
I have the following console application and am attempting to late bind
a class with option strict on! However of course I cant and I get the
following error "Option Strict On disallows late...
|
by: GS |
last post by:
I have installed the ms PIA for ofc XP, and followed the article
http://support.microsoft.com/kb/247412/
trying to paste into a worksheet
However I got late binding not allowed errors
.......
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
| |