2016-09-26 7 views
-1

次のスクリプトは、5行目で 'end of statement is expected'エラーを表示しています。私は正しく動作する他の同様のスクリプトを持っていますが、3行目はありません。私はアイテムIDを持っていないラインを持っています。それはなぜライン2をそこに置くのかです。申し訳ありませんが、それは乱雑です - 私はこれで非常に新しいです!vbスクリプトで 'end of statementが必要です'

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ありがとう - 私はあなたのisnotnullを何も変えなかった。

+4

でそれを確認することができますか? – Steve

+0

VB.NETにはisnotnullというものはありません。あなたは 'IsNot Nothing'またはおそらく' IsNot DBNull.Value'を意味しましたか?データベースがnullの場合? – jmcilhinney

+1

行3の末尾にある '_'を削除します。 – Slai

答えて

0
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 
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 

DbNullNothingは異なるタイプです。あなたの実際のコードではなく、すべてが読めなくなります行番号付きamemdedバージョンを貼り付けることができますあなたは

If dataRow.IsNull("IMA_ItemID") 

または

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

それはうまくいきました - ありがとう! –

+0

軽微な変更 -

関連する問題