user2457518
user2457518

Reputation:

Argument type 'string' is not assignable to parameter type 'int' in enum reference

I have the following vb.net function:

Public Function GetTicketDocument(ByVal vTicketNumber As Int32, ByVal vDocumentType As TicketDocumentType) As String

    Dim objO_Int As New dtIntegration_v10_r1.OmniqueManager(mobjSecurity)
    Dim strTicketFormat As String = ""
    Dim strEFILE_GUID As String = ""

    Select Case vDocumentType

        Case TicketDocumentType.tdtEstimate
            strTicketFormat = "Estimate"
        Case TicketDocumentType.tdtRepairOrder
            strTicketFormat = "RepairOrder"
        Case TicketDocumentType.tdtInvoice
            strTicketFormat = "Invoice"
    End Select
    strEFILE_GUID = objO_Int.GetTicketDocument(vTicketNumber, strTicketFormat)

    Return strEFILE_GUID

End Function

and when I run the aspx page that is associated with this function I get the following error

Argument type 'string' is not assignable to parameter type 'int'

and this is the line of code that it references

mEFile_GUID = objMain.GetTicketDocument(txtTicketNumber.Text, mTicketStage_ID);

one would think all you would have to do is something like this

mEFile_GUID = objMain.GetTicketDocument(Convert.ToInt32(txtTicketNumber.Text), mTicketStage_ID);

However when I do that I get this error that I have no idea how to fix

Argument type 'int' is not assignable to parameter type 'dtlService_v10_r1.Manager.TicketDocumentType'

Has anyone encountered this before? I can post the dll 'dtlService_v10_r1' if needed but it is quite lengthy just so you know

Oh probably some important information as well is that this is a conversion process from vb.net to c# and we are keeping the function in vb.net. I don't know if that is needed information or not but I like to give as much information as I can

Upvotes: 0

Views: 2888

Answers (1)

Magnus
Magnus

Reputation: 46909

It is the 2'nd parameter that is your current problem. You need to cast it into the correct enum type.

Dim vTicketNumber  = Convert.ToInt32(txtTicketNumber.Text)
Dim vDocumentType  = DirectCast(mTicketStage_ID, TicketDocumentType)
mEFile_GUID = objMain.GetTicketDocument(vTicketNumber, vDocumentType)

Upvotes: 1

Related Questions