Upgrade from Vb to VB.net

rk03

Member
Joined
Jun 26, 2006
Messages
8
Programming Experience
3-5
Hello,i upgraded from VB to VB.NET for better performance and avoid out of memory exceptions.However, i recieve a "System_COMObject" runtime error at the point where there is a usage of TypeNameTypeName(x)gives a com error.i did try to use Cstr(x) but it says X cannot be assigned to type string.Please help!Thanks,R.
 
So what is 'x'? Perhaps you should post some code and explain a little better.
 
Let me guess.... you took your VB6 project and ran it through the "upgrade" wizard didn't you? If that's the case.... toss it all out. Right now. Serious.

Then once you've tossed it out, and you've had few beers, cursed my name and rued the day I replied to this thread; pick yourself up, grab some paper, a pencil and start re-designing, and build the code from scratch.

-tg
 
There may be... there may not be..... however.... the question is whether it's worth the effort or not. In most cases it's easier & faster to just re-write the app using all .NET code rather than just running the upgrade.

-tg
 
I Hope the existing code can be reworked...Please findthe code below..-------------------------------------------If (Wizard4.DefInstance.UpdateReferences) And (CurrentReq.DocumentReferences.Count > 0) Then ' Copy the requirement document references into an updateable collection CurrentDocRefs = CurrentCollectionFactory.CreateByIStCollection(CurrentReq.DocumentReferences) i = CurrentDocRefs.Count - 1 CurrentIndex = 0 For j = 0 To i CurrentRef = (CurrentDocRefs.Item(CurrentIndex)) 'UPGRADE_WARNING: TypeName has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"' Select Case TypeName(CurrentRef) Case "FileReference" 'UPGRADE_WARNING: Couldn't resolve default property of object CurrentRef. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' UpdateFileRef(CurrentSession, CurrentDocRefs, CurrentRef, CurrentIndex, NumUpdates) Case "WebReference" ' increment counter until code written 'UPGRADE_WARNING: Couldn't resolve default property of object CurrentRef. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' UpdateWebRef(CurrentSession, CurrentDocRefs, CurrentRef, CurrentIndex, NumUpdates) Case "TextReference" ' Increment counter to skip this reference CurrentIndex = CurrentIndex + 1 Case Else 'UPGRADE_WARNING: TypeName has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"' MsgBox("Found unexpected reference type:" & vbCrLf & TypeName(CurrentRef), MsgBoxStyle.OKOnly, "Unexpected reference type") ' Increment counter to skip this reference CurrentIndex = CurrentIndex + 1 End Select Next j ' Update the requirement references with the updated collection CurrentReq.DocumentReferences = CurrentDocRefs End If ----------------------------------------------------------------- Select Case TypeName(CurrentRef) is where the system._typeObject error is being recieved.Would appreciate any help in this regard.Thanks,Rk03
 
don'ttakethis thewrongway butitisveryhardtoread codwhen itisallslammedtogether likethat justlikeitis veryhardtoread thistextbecauseIamnotusingspaces.

1) Use [code][/code] around your code to make it more readable.
2) Supply the original code with notes that show where the probelms are and what it is... not the detailed stuff you've got above (a lot of it is extraneous and useless in this case.)

-tg
 
Code once again

If (Wizard4.DefInstance.UpdateReferences) And (CurrentReq.DocumentReferences.Count > 0) Then CurrentDocRefs = CurrentCollectionFactory.CreateByIStCollection(CurrentReq.DocumentReferences) i = CurrentDocRefs.Count - 1 CurrentIndex = 0 For j = 0 To i CurrentRef = (CurrentDocRefs.Item(CurrentIndex)) Select Case TypeName(CurrentRef)This last line generates a runtime error system._COmObject.
 
Do you really expect us to read that code? As TechGnome already posted, use the tags to format your code. Also, however you're copying it is obviously removing all the line breaks so it's up to you to either change the way you're copying the code or put the line breaks back in manually. The harder you make it for us to help, the less likely it is that we will.
 
VB.NET:
If (Wizard4.DefInstance.UpdateReferences) And (CurrentReq.DocumentReferences.Count > 0) Then
    CurrentDocRefs = CurrentCollectionFactory.CreateByIStCollection(CurrentReq.DocumentReferences)
    i = CurrentDocRefs.Count - 1 
    CurrentIndex = 0

    For j = 0 To i 
        CurrentRef = (CurrentDocRefs.Item(CurrentIndex))

        Select Case TypeName(CurrentRef)

This last line generates a runtime error system._COmObject.
 
Last edited by a moderator:
Posting the complete code again

I Hope the existing code can be reworked...Please findthe code below..-------------------------------------------
VB.NET:
If (Wizard4.DefInstance.UpdateReferences) And (CurrentReq.DocumentReferences.Count > 0) Then
    CurrentDocRefs = CurrentCollectionFactory.CreateByIStCollection(Cur rentReq.DocumentReferences)
 
    i = CurrentDocRefs.Count - 1 
    CurrentIndex = 0

    For j = 0 To i
        CurrentRef = (CurrentDocRefs.Item(CurrentIndex)) 
 
        Select Case TypeName(CurrentRef) 
            Case "FileReference" 
                UpdateFileRef(CurrentSession, CurrentDocRefs, CurrentRef, CurrentIndex, NumUpdates)
 
            Case "WebReference"
                UpdateWebRef(CurrentSession, CurrentDocRefs, CurrentRef, CurrentIndex, NumUpdates) 
 
            Case "TextReference" ' 
                CurrentIndex = CurrentIndex + 1 
 
            Case Else
                MsgBox("Found unexpected reference type:" & vbCrLf & TypeName(CurrentRef), MsgBoxStyle.OKOnly, "Unexpected reference type") 
                CurrentIndex = CurrentIndex + 1
        End Select 
    Next j 
 
    CurrentReq.DocumentReferences = CurrentDocRefs 
End If
----------------------------------------------------------------- Select Case TypeName(CurrentRef) is where the system._typeObject error is being recieved.
Since TypeName(CurrentRef) has a value of System._typeObject the control is transferred to the bottom of the case statement to the giving a message box saying "Unexpected Reference Type"


Would appreciate any help in this regard.

Thanks and apologise for the code paste issues.
,Rk03
 
Last edited by a moderator:
CurrentRef is defined as Dim CurrentRef As CaliberRM.DocumentReferenceI am referencing the caliber API.Thanks,rk03
 
is there any other property of the CurrentRef object that you can use to determine what to do? i.e. does it have to be the result of typename() ?


perhaps also it might help if you post the old vb6 code that worked.. if it's any different?
 
Back
Top