|
-
Jul 30th, 2003, 10:39 AM
#1
Thread Starter
Hyperactive Member
Why do I get this error write I write OPTION STRICT ON? with this code
Why do I get this error write I write OPTION STRICT ON? with this code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
XmlSchema11.ReadXml(Application.StartupPath & "\..\Data\GRID.XML", FileMode.Open)
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
XmlSchema11.WriteXml(Application.StartupPath & "\..\Data\GRID.XML", FileMode.Open)
End Sub
I get this error:
C:\Documents and Settings\Telemetrika.Com\Desktop\XMLGrid\Form1.vb(111): Overload resolution failed because no accessible 'ReadXml' can be called with these arguments:
'Public Function ReadXml(fileName As String, mode As System.Data.XmlReadMode) As System.Data.XmlReadMode': Option Strict On disallows implicit conversions from 'System.IO.FileMode' to 'System.Data.XmlReadMode'.
'Public Function ReadXml(reader As System.IO.TextReader, mode As System.Data.XmlReadMode) As System.Data.XmlReadMode': Value of type 'String' cannot be converted to 'System.IO.TextReader'.
'Public Function ReadXml(reader As System.IO.TextReader, mode As System.Data.XmlReadMode) As System.Data.XmlReadMode': Option Strict On disallows implicit conversions from 'System.IO.FileMode' to 'System.Data.XmlReadMode'.
'Public Function ReadXml(stream As System.IO.Stream, mode As System.Data.XmlReadMode) As System.Data.XmlReadMode': Value of type 'String' cannot be converted to 'System.IO.Stream'.
'Public Function ReadXml(stream As System.IO.Stream, mode As System.Data.XmlReadMode) As System.Data.XmlReadMode': Option Strict On disallows implicit conversions from 'System.IO.FileMode' to 'System.Data.XmlReadMode'.
'Public Function ReadXml(reader As System.Xml.XmlReader, mode As System.Data.XmlReadMode) As System.Data.XmlReadMode': Value of type 'String' cannot be converted to 'System.Xml.XmlReader'.
'Public Function ReadXml(reader As System.Xml.XmlReader, mode As System.Data.XmlReadMode) As System.Data.XmlReadMode': Option Strict On disallows implicit conversions from 'System.IO.FileMode' to 'System.Data.XmlReadMode'.
-
Jul 30th, 2003, 10:52 AM
#2
It tells you exactly why.
'Public Function ReadXml(fileName As String, mode As System.Data.XmlReadMode) As System.Data.XmlReadMode': Option Strict On disallows implicit conversions from 'System.IO.FileMode' to 'System.Data.XmlReadMode'.
There is no ReadXML that takes System.IO.Filemode as a paremeter. It uses Syste.Data.XmlreadMode
-
Jul 30th, 2003, 10:55 AM
#3
Addicted Member
Because Option Strict On doesn't allow any implicit conversions. That means that it won't be able to look at "FileMode.Open",which is actually "System.IO.FileMode.Open" which has a value of 3, and convert it to a "System.Data.XMLReadMode". The equivelant "System.Data.XMLReadMode" value to "FileMode.Open" is "System.Data.XmlReadMode.InferSchema".
HTH.
-
Jul 30th, 2003, 10:56 AM
#4
Addicted Member
LOL Cander. You beat me to the punch.
-
Jul 30th, 2003, 11:00 AM
#5
-
Jul 30th, 2003, 12:37 PM
#6
Thread Starter
Hyperactive Member
How should I re-write the Load Form event then?
-
Jul 30th, 2003, 12:52 PM
#7
Sleep mode
Turn OPTION STRICT off and try , Or there's nothing wrong with your sub , you should pass the right data type .
-
Jul 30th, 2003, 01:13 PM
#8
Thread Starter
Hyperactive Member
Pirate:
The sub works just fine When I turn Option Strict Off.
I need Option Strict to be ON so what can I do to make this sub work.
Should I attach a small example?
-
Jul 30th, 2003, 01:23 PM
#9
We already answered the question. Sheppe in particular.
-
Jul 30th, 2003, 01:23 PM
#10
Sleep mode
What SUB are you getting problems with (your code is unreadable without vb tags)? again if the program is working well , keep OPTION STRICT off .
-
Jul 30th, 2003, 01:24 PM
#11
Frenzied Member
Do what pirate said. Pass in the right data type.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|