Re: DVB file

#31
Try this:

Code: Select all

Sub DynamicFormLoad(d_Form As Variant, d_Handle As String)
    Dim t_SREF As BlockInsert                                'was AcadBlockReference
    Dim t_SATT As Attributes
    Dim t_Index As Integer
    Dim t_FATT As Variant
    Set t_SREF = ActiveDocument.HandleToObject(d_Handle)     'was ThisDrawing
    If (t_SREF.HasAttributes) Then
        Set t_SATT = t_SREF.GetAttributes
        For t_Index = 0 To t_SATT.Count
            On Error GoTo DynamicFormLoad1
            Set t_FATT = d_Form.Controls.Item(t_SATT(t_Index).TagString)
            t_FATT.Text = t_SATT(t_Index).TextString
DynamicFormLoad2:
            On Error GoTo 0
            Next t_Index
        End If
    d_Form.Tag = d_Handle
    Exit Sub
DynamicFormLoad1:
    Resume DynamicFormLoad2
End Sub

Re: DVB file

#33
I have made a little more progress, but tripped over another issue.

The code so far checks fro the drawing border being present in the drawing, and if it is proceeds to check for associated attribute and their values.
It then opens the specified dialog box and populates it with the known values.

With this dialog the user can now edit all of the individual attributes then select 'ok' (save attribute values) or 'cancel'

The following code is the 'save values'

Code: Select all

Sub DynamicFormSave(d_Form As Variant, d_Handle As String)
    Dim t_SREF As BlockInsert                               'was AcadBlockReference
    Dim t_SATT As Attributes                                'was Variant  *****Quan
    Dim t_Index As Integer
    Dim t_FATT As Variant                                   'Dim t_FATT As Control
    Set t_SREF = ThisDocument.HandleToObject(d_Handle)      'was ThisDrawing
    If (t_SREF.HasAttributes) Then
        Set t_SATT = t_SREF.GetAttributes                   'was t_SATT = t_SREF.GetAttributes**Quan
        ThisDocument.Layers.Item("0").Lock = False          'was ThisDrawing
        For t_Index = 0 To t_SATT.Count                     '****Quan was For t_Index = LBound(t_SATT) To UBound(t_SATT)
            On Error GoTo DynamicFormSave1
            Set t_FATT = d_Form.Controls.Item(t_SATT(t_Index).TagString)
            t_SATT(t_Index).TextString = Trim$(t_FATT.Text) 		'**********current issue**********
DynamicFormSave2:
            On Error GoTo 0
            Next t_Index
        ThisDocument.Layers("0").Lock = True                'was ThisDrawing
        End If
    Exit Sub
DynamicFormSave1:
    Resume DynamicFormSave2
End Sub
I've tried to highlight the current problem (and all changes made to get to the latest issue)
The specific issue flagged is "Trim$"

I believe the code is checking for leading/trailing 'spaces' and removing them.
Any offers of help appreciated.


SteveN

Re: DVB file

#35
Thanks Quan,

OK, so I was right that the code is intended to remove the spaces at the start and end of the text string.
I found this link helpful in understanding the Trim function.
https://excelchamps.com/vba/functions/trim/ along with this one https://www.aivosto.com/articles/stringopt.html#variant for Trim / Trim$

sadly I'm no further forward, in terms of the error :(

This is the current problem code:
t_SATT(t_Index).TextString = Trim$(t_FATT.Text)

When debugging via F8 the debugger stops at this line and highlights 'Trim$'
with the error "Can't find Projct or Library"

What am I missing?
SteveN
PS, I'm using Icad 10.1 for this as an earlier code statement crashes Icad11.0!!

Re: DVB file

#36
Hi Steven,
The Trim$ works on my IntelliCAD 11.
We can rewrite the Trim$ function using the basic function (LTrim, RTrim).
This's a simple function:

Code: Select all

Function TrimFunction(str As String)
    While Left(str, 1) = " "
        str = Replace(str, " ", "", 1, 1)
    Wend    
    str = StrReverse(str)
    While Left(str, 1) = " "
        str = Replace(str, " ", "", 1, 1)
    Wend    
    TrimFunction = StrReverse(str)
End Function

Sub test()
    Dim str As String
    str = "   123 456   "
    str = TrimFunction(str)
'    MsgBox (str)
End Sub

Re: DVB file

#41
QuanNguyen wrote:
Wed Nov 30, 2022 1:23 am
Hi Steven,
The Trim$ works on my IntelliCAD 11.
We can rewrite the Trim$ function using the basic function (LTrim, RTrim).
This's a simple function:

Code: Select all

Function TrimFunction(str As String)
    While Left(str, 1) = " "
        str = Replace(str, " ", "", 1, 1)
    Wend    
    str = StrReverse(str)
    While Left(str, 1) = " "
        str = Replace(str, " ", "", 1, 1)
    Wend    
    TrimFunction = StrReverse(str)
End Function

Sub test()
    Dim str As String
    str = "   123 456   "
    str = TrimFunction(str)
'    MsgBox (str)
End Sub
I've just tried adding your code to my modules and running the testsub via F8 I get the same error on

Code: Select all

While Left(str, 1) = " "
with Left highlighted.
So I'm guessing that I still have an install problem!!

So another uninstall looks on the cards.
NOTE: I've seen other threads were users are having problems requiring more that one uninstall/reinstall to get an apparent working setup.
Concerning.

SteveN

Re: DVB file

#45
Well I setup my old win 10 PC, uninstalled any/all Icad versions.
Fresh install of version 9.0, same result.
Fresh install of version 10.1, same result.
Fresh install of version 11.0, same result.

So neither of my computers, win 10 or 11 will run the vba past the error above.

I'll fire up my laptop in the morning and see how that performs.

SteveN