Dim name As String = "hello"
If CType(My.Application.OpenForms(name), Faker) Is Nothing Then
New Faker() With {.Name = name, .Title = String.Format("{0} - ID:{1}", "hello", Me.ClassClient.ClientAddressID)}.Show()
End If
New 中的語法錯誤,如果我洗掉所有代碼并使用 {} 和 F.show() 撰寫 Dim F As New Faker() 沒有錯誤但不起作用,并且在運行程式物件參考時給我錯誤未設定為實體目的
有人可以幫我嗎
uj5u.com熱心網友回復:
這里有兩個答案在 VB.Net 中構造一個物件并呼叫一個沒有賦值的方法,這應該會有所幫助。
- 采用
With ... End With - 采用
Call
我認為您遇到了問題,因為您嘗試使用 C# 樣式來創建物件的實體,而不在鏈接方法呼叫之前對其進行分配。
您的代碼變為:
Dim name As String = "hello"
If CType(My.Application.OpenForms(name), Faker) Is Nothing Then
With New Faker() With {.Name = name, .Title = String.Format("{0} - ID:{1}", "hello", Me.ClassClient.ClientAddressID)}
.Show()
End If
要么
Dim name As String = "hello"
If CType(My.Application.OpenForms(name), Faker) Is Nothing Then
Call New Faker() With {.Name = name, .Title = String.Format("{0} - ID:{1}", "hello", Me.ClassClient.ClientAddressID)}.Show()
End If
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/455653.html
