类的多次使用
为什么我声明的两个字符串类只能使用一次? 情况如下: 我定义了两个 StringBuilder实例
sbPorts, sbTrans,第一次用在 flGetAvailableSpiPorts 方法中使用 它们,能通过编译。 但第二次在flGetAvailableSpiPorts 里使用则会报错,如果我在第二次flGetAvailableSpiPorts 里,将sbPorts, sbTrans换成sbPorts1, sbTrans1,则编译成功,这是为什么? 我怎么样才能再次使用sbPorts, sbTrans呢? 有类似VC的delect 回收函数吗?
Dim usMaxLen As UShort
Dim sbPorts As New StringBuilder("", 255)
Dim sbTrans As New StringBuilder("", 255)
Dim sbPorts1 As New StringBuilder("", 255)
Dim sbTrans1 As New StringBuilder("", 255)
Dim usCount As UShort
Dim status As Integer
status = TestFlash.flGetAvailableSpiPorts(usMaxLen, sbPorts, sbTrans, usCount)
If status <> TFL_OK And usMaxLen <> 0 Then
'sbPorts = Nothing
'sbTrans = Nothing
'sbPorts As New StringBuilder("", 255)
status = TestFlash.flGetAvailableSpiPorts(usMaxLen, sbPorts1, sbTrans1, usCount)
End If
If status <> TFL_OK Or usMaxLen = 0 Then
End If
[解决办法]
'sbPorts As New StringBuilder("", 255)
sbPorts = New StringBuilder("", 255)