2016-09-26 66 views
-1

下面的腳本是給我的「語句的結束,預計」錯誤在第5行。我有一個正常運行的其他類似的腳本,但沒有3號線。我有行沒有項目ID,這就是爲什麼我把第2行在那裏。對不起,如果它很混亂 - 我很新!接收VB腳本「語句的結束,預計」

Private Sub Export_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) 
    If GetCurrentColumnValue("IMA_ItemID") Is Nothing Or GetCurrentColumnValue("IMA_ItemID") IsDBNull Then 
     Me.Export.text = "" _ 
    ElseIf GetCurrentColumnValue("IMA_ItemID") isnotnull AND GetCurrentColumnValue("IMA_CountryOfOrigin") = "USA" Then 
     Me.Export.text = "*** These commodities, technology, or software were exported from the United States in accordance with the Export Administration Regulations. Diversion contrary to United States law is prohibited." 
    Else 
     Me.Export.text = "" 
    End If 
End Sub 

在我放入第2行之前,它看起來像這樣。不過,當時我在打印時當的itemid爲null得到一個錯誤:

Private Sub Export_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) 
    If GetCurrentColumnValue("IMA_CountryOfOrigin") = "USA" Then 
     Me.Export.text = "*** These commodities, technology, or software were exported from the United States in accordance with the Export Administration Regulations. Diversion contrary to United States law is prohibited." 
    Else 
     Me.Export.text = "" 
    End If 
End Sub 

感謝

這裏是沒有行號的代碼。對不起 - 我認爲這樣可以讓我更容易理解我的問題:並且謝謝jmcilhinney - 我改變了我的無知並不是什麼都沒有。

Private Sub Export_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) 
    If GetCurrentColumnValue("IMA_ItemID") Is Nothing Or GetCurrentColumnValue("IMA_ItemID") IsDBNull Then 
     Me.Export.text = "" _ 
    elseIf GetCurrentColumnValue("IMA_ItemID") IsNot Nothing _ 
      AND GetCurrentColumnValue("IMA_CountryOfOrigin") = "USA" _ 
     Then 
      Me.Export.text = "*** These commodities, technology, or software were exported from the United States in accordance with the Export Administration Regulations. Diversion contrary to United States law is prohibited." 
     Else 
      Me.Export.text = "" 
    End If 
End Sub 
+4

可以粘貼你的真正的代碼,而不是一個amemded版本的行號,使一切不可讀? – Steve

+0

在VB.NET中沒有'isnotnull'這樣的東西。如果是數據庫null,你的意思是'IsNot Nothing'或者'IsNot DBNull.Value'嗎? – jmcilhinney

+1

在3線 – Slai

回答

0
Private Sub Export_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) 
    If GetCurrentColumnValue("IMA_ItemID") <> DBNull.Value AndAlso 
      GetCurrentColumnValue("IMA_CountryOfOrigin").ToString = "USA" Then 
     Me.Export.text = "*** These commodities, technology, or software were exported from the United States in accordance with the Export Administration Regulations. Diversion contrary to United States law is prohibited." 
    Else 
     Me.Export.text = "" 
    End If 
End Sub 

DbNull是不同的類型Nothing。您可以檢查它

If dataRow.IsNull("IMA_ItemID") 

If dataRow("IMA_ItemID") = DBNull.Value 
+0

工作 - 謝謝! –

+0

輕微變化 - 必須將<> DBNull.Value更改爲isnot沒有,然後它工作得很好!再次感謝大家! –