How can I use this code:
VB6.LoadResString(i)
without getting this warning:
Public Function LoadResString(ID As Integer) As String is obsolete:
'Microsoft.VisualBasic.Compatibility.* classes are obsolete and supported
within 32 bit processes only. http://go.microsoft.com/fwlink/?linkid=160862'.
The posted link in the error and other info in the MSDN site only say to me "ehy, this is obsolete in your framework, don't use it", but what if I need it (Loads a string from a resource (.res) file.)?
How can I write it without getting that warning message?
UPDATE: Thanks, but nothing worked...
Related
I can't seem to get past this error that appears with this code block:
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", True).SetValue("cmd /C")
The full error is as follows:
BC30516 Visual Basic AND VB.NET Overload resolution failed because no accessible accepts this number of arguments.
Looked all over for solutions and none seem to exist or work.
Any help would be appreciated.
OpenSubKey returns a RegistryKey and SetValue needs at least 2 parameters. You are only passing one. There are good example in the documentation.
I followed examples of RaisePropertyChanged for the MVVM Light libraries in a WPF application. This seems like it should be valid. Event the code hints seem to think so. But when I build, Visual Studio gives me an error and then highlights RaisePropertyChanged with light blue squiggleys. Anyone seen this issue? Is there something obvious I'm missing?
Private _selectedServerInstance As String
Property SelectedServerInstance As String
Get
Return _selectedServerInstance
End Get
Set(value As String)
_selectedServerInstance = value
RaisePropertyChanged(Function() Me.SelectedServerInstance) //Error on build
End Set
End Property
' Looks ok until I build. The Error for each line with RaisePropertyChanged using a lambda property selector is:
' error BC30518: Overload resolution failed because no accessible 'RaisePropertyChanged' can be called with these arguments:
for RaisePropertyChanged:
References required to assemblies 'System.Linq.Expressions', 'System.Runtime', 'System.ObjectModel'.
Check References in your project.
System.Runtime and System.ObjectModel are not in the list of references to choose. Is this because they are 'facade' references, and rarely get used except in the crazy case of mvvm-light?
I have been rewriting some of my old VBscript code to VB code.I am almost done with everything but I get an error at one place.
VB Script
Session("FirstName") = Request.Cookies("FirstName").Item
VB
Session.Add("FirstName", Request.Cookies("FirstName").Item)
and the error is
BC30455: Argument not specified for parameter 'key' of 'Public Default Property Item(key As String) As String'.
Can anybody tell me how to correct this error or atleast what does the error mean?
Thanks in advance.
Session.Add("FirstName", Request.Cookies("FirstName"))
should work , when you use .Item it is expecting a key for Item such as:
Session.Add("FirstName", Request.Cookies("FirstName").Item("ItemKey"))
This is at least a documentation error, if not a bug.
In VB.NET prior to .NET 4.0 (i.e. VB.NET 7 through 9) an empty Structure declaration fails at compile-time with
error BC30281: Structure 'MySimpleEmpty' must contain at least one instance member variable or Event declaration.
E.g. The following two structures compile successfully in VB10, and not prior:
Structure MySimpleEmpty
End Structure
Public Structure AnotherEmpty
Public Const StillEmpty As Boolean = True
End Structure
I note the documentation for the Error BC30281 stops at VB9, but the documentation for the Structure statement still has the datamemberdeclarations as required even as of VB11 (.NET 4.5 VS2012).
These two Structures compile in VB11 (VS2012) as well. (Thanks John Woo.)
Is there some blog entry or documentation confirming this is an intended change or a bug in VB10 and later?
Microsoft have marked this as a fixed bug, without actually stating what was fixed.
The VB11 (VS2012) documentation now says the datamemberdeclarations are optional in the grammar, but in the Parts table it says "Required. Zero or more..."!
I guess that's a fix... The VB10 (VS2010) documentation hasn't been changed.
i'm talking to a COM object (Microsoft ADO Recordset object). In a certain case the recordset will return a failed (i.e. negative) HRESULT, with the message:
Item cannot be found in the collection
corresponding to the requested name or
ordinal
i know what this error message means, know why it happened, and i how to fix it. But i know these things because i read the message, which fortunately was in a language i understand.
Now i would like to handle this exception specially. The COM object threw an HRESULT of
0x800A0CC1
In an ideal world Microsoft would have documented what errors can be returned when i try to access:
records.Fields.Items( index )
with an invalid index. But they do not; they most they say is that an error can occur, i.e.:
If Item cannot find an object in the
collection corresponding to the Index
argument, an error occurs.
Given that the returned error code is not documented, is it correct to handle a specific return code of `0x800A0CC1' when i'm trying to trap the exception:
Item cannot be found in the collection
corresponding to the requested name or
ordinal
?
Since Microsoft didn't document the error code, they technically change it in the future.
They did document this error code, but it's hard to find:
ErrorValueEnum:
adErrItemNotFound 3265 -2146825023 0x800A0CC1 Item cannot be found in the collection that corresponds to the requested name or ordinal.
..so, as its' a documented error code, it is safe to test for it explicitly.
You'll have to decide whether or not it is worth the risk, but I believe that it is unlikely that Microsoft will change this error code. Checking for this particular error code is a pretty robust way to go.
Yes, it is fine. It is in fact a documented error code, although finding them is never easy. It is defined in the msdao15.idl Windows SDK file, adErrItemNotFound (error 3265)