Message 1 of 2
conversion from string "System._ComObject" to type "double" not valid
Not applicable
02-09-2011
08:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am trying to count the block references with the name "MISC4" in the modelspace drawing and then print the result on screen. I am using Cad11 (some computers here also run 2009) and VB 2010 Express.
I get a conversion error of 'conversion from String "System._ComObject" to type "double" not valid' ...
This problem is mainly a conversion issue to .net I believe but I can not figure out where or what variable is not being defined(or why). New to the .net so I might not be utilizing the new features to the full potential.
Here is the code, with commented debug values (sorry it is very ugly in this code block and the ''' should be on the same line for comments)...
<code>
Private Sub btnScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan.Click
Dim notes(100) As String
Dim blkNote As Object
Dim Scan As Integer
Dim err1 As Integer
Dim index As Integer
Dim blks As AcadBlockReference
Dim ent As AcadEntity
Dim newNotes(200) As String
For Each ent In ThisDrawing.ModelSpace If ent.ObjectName.ToString = "AcDbBlockReference" Then
blks = ent
If blks.Name = "MISC4" Then
Scan = 0
err1 = 0
Try
blkNote = blks.GetAttributes ''blkNote={object()}
Catch ex As Exception
blkNote = ""
End Try
While Scan < 100
If notes(Scan) = blkNote(0).ToString Then ''' notes(scan)=nothing so err1 = 0
err1 = 1
End If
Scan = Scan + 1
'Net.disableAutoRelease(notes) '''locks (notes) value '.disable' not a member of 'Net'
End While
If err1 = 0 Then
notes(index) = blkNote(0).ToString '''notes(index) = "System._ComObject"
'''notes(index) = "nothing" after Step Into
index = index + 1
End If
End If
End If
Next ent
Scan = 0
While Scan < 100
If notes(Scan) > 100 Then '''breaks here '''conversion from string "System._ComObject" to type "double" not valid
newNotes(Scan + 100) = notes(Scan)
Else
newNotes(notes(Scan)) = notes(Scan)
End If
Scan = Scan + 1
End While
Scan = 0
While Scan < 200
If newNotes(Scan) <> "" Then
Try
lbNotes.Items.Add(newNotes(Scan))
Catch ex As Exception
End Try
End If
Scan = Scan + 1
End While
End Sub</code>
Thank you for any help, it is greatly appreciated.
JS