日期:2014-05-18  浏览次数:20443 次

求助变量 ? 在赋值前被使用。。。
我要对变动的字符代码逐字到数据库中,解析并叠加显示出来...
可出现说变量   R   在赋值前被使用。

        Public   Function   StaFormat(ByVal   Typ   As   Integer,   ByVal   Str   As   String)   As   String
                If   (Typ   <>   " ")   And   (Not   Str   Is   Nothing)   Then
                        Dim   i   As   Integer
                        Dim   R   As   String
                        Dim   TempCommand   As   OleDbCommand
                        Dim   TempReader   As   OleDbDataReader
                        MyConnection.Open()
                        For   i   =   1   To   Len(Trim(Str))
                                TempCommand   =   New   OleDbCommand( "   SELECT   *   FROM   VEH_CODE   WHERE   DMLB= "   &   Typ   &   "   AND   DMZ= ' "   &   Mid(Str,   i,   1)   &   " '   ",   MyConnection)
                                TempReader   =   TempCommand.ExecuteReader
                                If   i   =   1   Then
                                        R   =   CStr(TempReader( "DMSM1 "))
                                Else
                                        R   =   CStr(R   &   ", "   &   TempReader( "DMSM1 "))
                                End   If
                        Next
                        MyConnection.Close()
                        Return   R
                Else
                        Return   Nothing
                End   If
        End   Function

------解决方案--------------------
try

Dim R As String
--->
Dim R As String = " "

另外Typ是Integer,这里怎么直接跟String做比较
If (Typ <> " ") And (Not Str Is Nothing) The