I do not understand why I am getting a "Specified cast is not valid" error, since it has worked before. Something has changed and I am not really sure what it could be. I am looking for something along the lines of did you check this, have you did this, or this is the wrong way of doing this. I can access the CColPositions and the CPosition class, but when I try to use the two classes in a For...Next loop I get the error message above. Should I rebuild my VB6DLLFile and reference it in my project
In the Page_Load Event I have
Dim _posCollection As New CColPosition
Dim _pos As New CPositio
Dim strSSN As Strin
_posCollection.Retrieve(strSSN
For Each _pos In _posCollection '<----I get the error at this lin
Response.Write(_pos.PrimaryJobTitle
Nex
--------CColPositions-------
Namespace Employe
Public Class CColPosition
Inherits VB6DLLFile.colPositionsClas
End Clas
End Namespac
--------CPosition Class-------
Namespace Employe
Public Class CPositio
Inherits VB6DLLFile.clsPositionClas
End Clas
End Namespac
Thanks
Charle 8 1737
Please post the line of code that the Exception refers to, or indicate which
line of code is in the code you did post.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Charles" <an*******@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com... I do not understand why I am getting a "Specified cast is not valid"
error, since it has worked before. Something has changed and I am not
really sure what it could be. I am looking for something along the lines of
did you check this, have you did this, or this is the wrong way of doing
this. I can access the CColPositions and the CPosition class, but when I
try to use the two classes in a For...Next loop I get the error message
above. Should I rebuild my VB6DLLFile and reference it in my project? In the Page_Load Event I have: Dim _posCollection As New CColPositions Dim _pos As New CPosition Dim strSSN As String _posCollection.Retrieve(strSSN) For Each _pos In _posCollection '<----I get the error at this line Response.Write(_pos.PrimaryJobTitle) Next
--------CColPositions-------- Namespace Employee Public Class CColPositions Inherits VB6DLLFile.colPositionsClass End Class End Namespace
--------CPosition Class-------- Namespace Employee Public Class CPosition Inherits VB6DLLFile.clsPositionClass End Class End Namespace
Thanks! Charles
Hi, Bi
Thanks for the reply
I did forget to say that it used to work using For...Next loops at one time too. The VB6DLLFiles do have some code in the classes so that For...Next can be used. So I am not real sure if System.IEnumerable will work out. But that is a tomorrow morning project since it is 5:15pm here
Thanks again
Charle
----- Bin Song, MCP wrote: ----
Hi, Charles
The collection class must implements System.IEnumerable in order to be enumerated
Bin Song, MCP
I would put a breakpoint on the problem line, and see what the type makeup
of your collection is. You might be better off iterating with a counter, and
doing a ctype or directcast if the type is actually appropriate. If it
isn't, try re-defining your collection class based on
system.collections.collectionbase, and override the Add (etc.) methods for
strong typing.
"Charles" <an*******@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com... I do not understand why I am getting a "Specified cast is not valid"
error, since it has worked before. Something has changed and I am not
really sure what it could be. I am looking for something along the lines of
did you check this, have you did this, or this is the wrong way of doing
this. I can access the CColPositions and the CPosition class, but when I
try to use the two classes in a For...Next loop I get the error message
above. Should I rebuild my VB6DLLFile and reference it in my project? In the Page_Load Event I have: Dim _posCollection As New CColPositions Dim _pos As New CPosition Dim strSSN As String _posCollection.Retrieve(strSSN) For Each _pos In _posCollection '<----I get the error at this line Response.Write(_pos.PrimaryJobTitle) Next
--------CColPositions-------- Namespace Employee Public Class CColPositions Inherits VB6DLLFile.colPositionsClass End Class End Namespace
--------CPosition Class-------- Namespace Employee Public Class CPosition Inherits VB6DLLFile.clsPositionClass End Class End Namespace
Thanks! Charles
Sorry, I missed your note.
Without seeing the code that creates the Collection class, it's hard to say
for sure.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Charles" <an*******@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com... I indicated which line of code that I got the exception on by this line:
For Each _pos In _posCollection '<----I get the error at this line
Thanks for the reply! Charles
----- Kevin Spencer wrote: -----
Please post the line of code that the Exception refers to, or
indicate which line of code is in the code you did post.
-- HTH, Kevin Spencer ..Net Developer Microsoft MVP Big things are made up of lots of little things.
"Charles" <an*******@discussions.microsoft.com> wrote in message news:47**********************************@microsof t.com... > I do not understand why I am getting a "Specified cast is not
valid" error, since it has worked before. Something has changed and I am
not really sure what it could be. I am looking for something along the
lines of did you check this, have you did this, or this is the wrong way of
doing this. I can access the CColPositions and the CPosition class, but
when I try to use the two classes in a For...Next loop I get the error
message above. Should I rebuild my VB6DLLFile and reference it in my
project? >> In the Page_Load Event I have: > Dim _posCollection As New CColPositions > Dim _pos As New CPosition > Dim strSSN As String > _posCollection.Retrieve(strSSN) > For Each _pos In _posCollection '<----I get the error at
this line > Response.Write(_pos.PrimaryJobTitle) > Next >> --------CColPositions-------- > Namespace Employee > Public Class CColPositions > Inherits VB6DLLFile.colPositionsClass > End Class > End Namespace >> --------CPosition Class-------- > Namespace Employee > Public Class CPosition > Inherits VB6DLLFile.clsPositionClass > End Class > End Namespace >> Thanks! > Charles >
Hi, Charles
Do you mean it works in .NET or VB6? I can see that you interop the VB6 dll
What's the code in the classes so that For...Next can be used
Bin Song, MCP
It used to work in .NET. It still works in VB6
The code in the classes so that For...Next can be used is (VB6)
Public Property Get NewEnum() As IUnknow
'this property allows you to enumerat
'this collection with the For...Each synta
Set NewEnum = mCol.[_NewEnum
End Propert
Charle
----- Bin Song, MCP wrote: ----
Hi, Charles
Do you mean it works in .NET or VB6? I can see that you interop the VB6 dll
What's the code in the classes so that For...Next can be used
Bin Song, MCP
Thanks for everyones help. I decide just to access the VB6DLLFile directly. Hopefully I will not have other problems doing this.
Thanks again
Charle
----- Charles wrote: ----
I have found that if I access the VB6DLLFile directly, the For...Next loop does work. However, I would like to access the VB6DLLFile though a .NET project that will hold all the classes that come from VB6DLLFile (using Inherits) and new classes
Thanks
Charle
----- Charles wrote: ----
I do not understand why I am getting a "Specified cast is not valid" error, since it has worked before. Something has changed and I am not really sure what it could be. I am looking for something along the lines of did you check this, have you did this, or this is the wrong way of doing this. I can access the CColPositions and the CPosition class, but when I try to use the two classes in a For...Next loop I get the error message above. Should I rebuild my VB6DLLFile and reference it in my project
In the Page_Load Event I have
Dim _posCollection As New CColPosition
Dim _pos As New CPositio
Dim strSSN As Strin
_posCollection.Retrieve(strSSN
For Each _pos In _posCollection '<----I get the error at this lin
Response.Write(_pos.PrimaryJobTitle
Nex
--------CColPositions-------
Namespace Employe
Public Class CColPosition
Inherits VB6DLLFile.colPositionsClas
End Clas
End Namespac
--------CPosition Class-------
Namespace Employe
Public Class CPositio
Inherits VB6DLLFile.clsPositionClas
End Clas
End Namespac
Thanks
Charle This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Özden Irmak |
last post by:
Hello,
In my application, I've to cast DocumentDesigner class to my own derived
class,MyDocumentDesigner, in order to reach the protected properties in
DocumentDesigner class. But everytime I...
|
by: .Net Sports |
last post by:
I have a datagrid codebehind script that takes data from sql dbase and
displays it in a footer row as a total. One column has amount_dollars
(which works fine), while another has new sales (which...
|
by: .Net Sports |
last post by:
IN a datagrid code behind, I'm getting a "Specified cast is not valid"
error
price = (Decimal)(rowData);
which was initialized as:
Decimal price;
|
by: .Net Sports |
last post by:
I have a datagrid codebehind script that takes data from sql dbase and
displays it in a footer row as a total. One column has amount_dollars
(which works fine), while another has new sales (which...
|
by: Mike Cooper |
last post by:
There is something about inherited classes I evidently don't know...
I wrote the following class:
Class Class1
inherits System.Windows.Forms.DataGridTextBoxColumn
End Class
There is...
|
by: Jayyde |
last post by:
Not sure why all of a sudden this line of code:
cmbProductCategoryTreeDisplayName.SelectedIndex = 0;
is producing a "Specified cast is not valid error". In the watch it has 1
item in it at...
|
by: keithb |
last post by:
Using a GridView, I get a "Specified cast is not valid" error when binding
the Visible propery of a hyperlink control to a DataTable text field. The
error goes away if I replace the data binding...
|
by: vijayasingh |
last post by:
I am trying to take contacts data from out look and Synchronize with our database. I am using .net 1.1 framework.
iam using following code.
OLCont = MyOLList.GetLast 'CType(item,...
|
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= |
last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm
receiving a "Specified cast is not valid" error that has something to do w/
the keys involved. The stack trace is:
...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |