這是一個簡單的問題,但它一直讓我頭疼。我有一個很長的if
條件,而不是寫在一行上,我想寫在多行清晰。跨越多行的長表達式
我做了一些研究,並設法找到使用& _
,我可以在下一行寫下表達式。但是如果我寫的是這樣的:
If Not (DataGridView1.Rows(counter).Cells("User").Value Is Nothing) And & _
(DataGridView1.Rows(counter).Cells("id number").Value Is Nothing) And & _
(DataGridView1.Rows(counter).Cells("Emailaddress").Value Is Nothing) And & _
(DataGridView1.Rows(counter).Cells("Date").Value Is Nothing) And & _
(DataGridView1.Rows(counter).Cells("phone no.").Value Is Nothing) Then
....... 'do something here'
End If
的問題是把And & _
系統需要一個表達。我試着將& _
移到其他位置,例如:在IS Nothing
之前,但沒有運氣。
誰能幫我
您使用的是什麼版本的VB.NET?或者,因爲它可能更容易回答,Visual Studio的版本是什麼?你可能不需要打擾續行字符。 –
真的,它也適用,如果你只是刪除'&'或'&_'(VS2012)。 –
考慮閱讀[文檔](https://msdn.microsoft.com/en-us/library/aa711641(v = vs.71).aspx) –