VB.NET错误消息 - “Option Strict On禁止从'Object'到'String'的隐式转换”

时间:2011-07-05 11:46:07

标签: vb.net

我的VB.NET计划出错了。我已经尝试了各种演员等,但它只是不能解决问题 - 所以我不情愿地在这里发帖,看看是否有其他人有类似的问题。

错误消息

  

错误1选项Strict On禁止从“Object”到“String”的隐式转换。

代码

Private DS As New DataSet ' Languages
Function TransTxt(ByVal Frm As String, ByVal Item As String) As String

    Dim language As String
    Select Case My.Settings.Language
        Case 0 : language = "en" ' English
        Case 1 : language = "fr" ' French
        Case 2 : language = "it" ' Italian
        Case 3 : language = "sp" ' spanish
        Case 4 : language = "pt" ' portuguese
        Case 5 : language = "de" ' german
        Case 6 : language = "du" ' dutch
        Case Else : language = "en" ' English
    End Select


    Try 'ONE of these rows is the error
        Dim DR() As DataRow = DS.Tables(Frm).Select("Tag = '" & Item & "'")
        Return DR(0).Item(language) 
        Catch ex As Exception 
          Return "- error -" & Item
    End Try 
End Sub

1 个答案:

答案 0 :(得分:4)

Return DR(0).Item(language)是我的猜测。

CASTSTRING类型或最后使用Return DR(0).Item(language).ToString()