Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried to convert C# code to VB.Net but I am getting an Syntax error in the line inside brackets starting with the word (New SubmitDocumentRequest + ProcessSubmitDocumentRequestMessage())
How do I fix this?

Here is C# code
VB
try
{
    strMessageType = objXmlContentDoc.DocumentElement.LocalName;
    switch (strMessageType)
    {
        case  "SubmitDocumentRequestMessage":
            new SubmitDocumentRequest().ProcessSubmitDocumentRequestMessage(ref aobjXMLInputSoapEnvelopeDoc, ref objXmlContentDoc);
            break;
        default:
			throw new System.Exception("Unknown Message Type");
    }
 catch (System.Exception ex)
 {
    aobjBroker.PostMessageWarehouseInformationalMessage("System Error: " + ex.Message, 3);
        return;
}



Here is the code I converted to VB.Net with syntax error

VB
Try
    strMessageType = objXmlContentDoc.DocumentElement.LocalName
    Select Case strMessageType
		Case "SubmitDocumentRequestMessage"
			(New SubmitDocumentRequest + ProcessSubmitDocumentRequestMessage(aobjXMLInputSoapEnvelopeDoc, objXmlContentDoc))
		Case Else
            Throw New System.Exception("Unknown Message Type")
    End Select
Catch ex As System.Exception("System Error: " + ex.Message, 3)
    Return
End Try


What I have tried:

VB
Try
    strMessageType = objXmlContentDoc.DocumentElement.LocalName
    Select Case strMessageType
		Case "SubmitDocumentRequestMessage"
			(New SubmitDocumentRequest + ProcessSubmitDocumentRequestMessage(aobjXMLInputSoapEnvelopeDoc, objXmlContentDoc))
		Case Else
            Throw New System.Exception("Unknown Message Type")
    End Select
Catch ex As System.Exception("System Error: " + ex.Message, 3)
    Return
End Try
Posted
Updated 16-Jul-18 6:32am
Comments
F-ES Sitecore 16-Jul-18 12:12pm    
If you need to convert something to vb.net I'd suggest you actually learn the syntax, it's not massively different from c# To be honest if you can't see the issue with that conversion then I'd question if you even understand the c#
MadMyche 16-Jul-18 12:16pm    
What version of VB.Net? Have you changed compiler to match?
Member 11403304 16-Jul-18 12:32pm    
Thank for your suggestion. Point well taken.

You don't need the "+' sign to continue a ling of code on a new line.

You also have to return an object to call the method on. Your code seems to want to create an instance of "SubmitDocumentRequest.ProcessSubmitDocumentRequestMessage". That doesn't work for calling a method on an object.

To make your debugging life easier, don't use shortcuts. Try it this way:
VB.NET
Try
    strMessageType = objXmlContentDoc.DocumentElement.LocalName
    Select Case strMessageType
        Case "SubmitDocumentRequestMessage"
            Dim request As New SubbmitDocumentRequest
            request.ProcessSubmitDocumentRequestMessage(aobjXMLInputSoapEnvelopeDoc, objXmlContentDoc)
        Case Else
            Throw New System.Exception("Unknown Message Type")
    End Select
Catch ex As System.Exception("System Error: " + ex.Message, 3)
    Return
End Try
 
Share this answer
 
strMessageType is not declared first before using.
 
Share this answer
 
I no longer need help with this one.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900