views:

55

answers:

1

I have:

Protected Sub SepInsert(ByVal mriId As VariantType, 
                        ByVal aeId As VariantType, 
                        ByVal absId As VariantType)
...
End Sub

and want to call it with a DropDownList selection like this:

Protected Sub cmdNewPrelinkedMri_Click(ByVal sender As Object, 
                                       ByVal e As System.EventArgs
                                      ) Handles cmdNewPrelinkedMri.Click
    SepInsert(ddlMriUnassigned.SelectedValue, -1, -1)
End Sub

where the ddl selected value is, of course, a string (e.g., "0412B0").

I am getting an InvalidCastException saying: Conversion from string "0412B0" to type 'Integer' is not valid. Why does it want to convert to 'Integer' when the parameter is declared as VariantType?

What am I misunderstanding or doing wrong? Thanks,

Chris

+1  A: 

Some statement in SepInsert is trying to force mriId into an int. Show the whole code if you can't find it.

Sky Sanders
PS: You should try to avoid variants when at all possible. If you know it is a string type it as a string. just sayin....
Sky Sanders