Hi i am new in VB6 trying to built a simple application : 1 userform with 15 combobox, 46 Textbox and 3 command button. (ComboBox1~15)Each combobox is populated with items, TextBox1~15 are user input, Textbox17~46 are automatically filled by excel application to be executed by command button, then if my form is completely filled up, another command button will be executed to update current autocad open document with block attributes.

My Problem: I got Runtime Error 13 Type mismatch when i clicked command button to update current/running autocad document with block attributes.

Error is located here:

Sub UpdateAttrib(TagNumber As Integer, BTextString As String)

If BTextString = "" Then

Tatts(TagNumber).TextString = ""

Else

Tatts(TagNumber).TextString = BTextString

End If

End Sub

Entire code is attached here

Thanks in advance
ABS

Attachments
Option Explicit

Public acad As Object
Public doc As Object
Public ms As Object
Public ssnew As Object
Public Tatts As Variant
'declare global variables

Private Sub CommandButton1_Click()
        
    UpdateAttrib 0, UserForm1.ComboBox1.Text
    UpdateAttrib 1, UserForm1.ComboBox2.Text
    UpdateAttrib 2, UserForm1.ComboBox3.Text
    UpdateAttrib 3, UserForm1.ComboBox4.Text
    UpdateAttrib 4, UserForm1.ComboBox5.Text
    UpdateAttrib 5, UserForm1.ComboBox6.Text
    UpdateAttrib 6, UserForm1.ComboBox7.Text
    UpdateAttrib 7, UserForm1.ComboBox8.Text
    UpdateAttrib 8, UserForm1.ComboBox9.Text
    UpdateAttrib 9, UserForm1.ComboBox10.Text
    UpdateAttrib 10, UserForm1.ComboBox11.Text
    UpdateAttrib 11, UserForm1.ComboBox12.Text
    UpdateAttrib 12, UserForm1.ComboBox13.Text
    UpdateAttrib 13, UserForm1.ComboBox14.Text
    UpdateAttrib 14, UserForm1.ComboBox15.Text
    UpdateAttrib 15, UserForm1.TextBox15.Text
    UpdateAttrib 16, UserForm1.TextBox14.Text
    UpdateAttrib 17, UserForm1.TextBox13.Text
    UpdateAttrib 18, UserForm1.TextBox12.Text
    UpdateAttrib 19, UserForm1.TextBox11.Text
    UpdateAttrib 20, UserForm1.TextBox10.Text
    UpdateAttrib 21, UserForm1.TextBox9.Text
    UpdateAttrib 22, UserForm1.TextBox8.Text
    UpdateAttrib 23, UserForm1.TextBox7.Text
    UpdateAttrib 24, UserForm1.TextBox6.Text
    UpdateAttrib 25, UserForm1.TextBox5.Text
    UpdateAttrib 26, UserForm1.TextBox4.Text
    UpdateAttrib 27, UserForm1.TextBox3.Text
    UpdateAttrib 28, UserForm1.TextBox2.Text
    UpdateAttrib 29, UserForm1.TextBox1.Text
    UpdateAttrib 30, UserForm1.TextBox47.Text
    UpdateAttrib 31, UserForm1.TextBox46.Text
    UpdateAttrib 32, UserForm1.TextBox45.Text
    UpdateAttrib 33, UserForm1.TextBox44.Text
    UpdateAttrib 34, UserForm1.TextBox43.Text
    UpdateAttrib 35, UserForm1.TextBox42.Text
    UpdateAttrib 36, UserForm1.TextBox41.Text
    UpdateAttrib 37, UserForm1.TextBox40.Text
    UpdateAttrib 38, UserForm1.TextBox39.Text
    UpdateAttrib 39, UserForm1.TextBox38.Text
    UpdateAttrib 40, UserForm1.TextBox37.Text
    UpdateAttrib 41, UserForm1.TextBox36.Text
    UpdateAttrib 42, UserForm1.TextBox35.Text
    UpdateAttrib 43, UserForm1.TextBox34.Text
    UpdateAttrib 44, UserForm1.TextBox33.Text
    UpdateAttrib 45, UserForm1.TextBox32.Text
    
    'get the attribute values
    
    ssnew.Item(0).Update
    'update the attribute block
    
    'delete the selection set
    'acad.SelectionSets.Item("TBLK2").Delete
   
        
End Sub

Private Sub CommandButton3_Click()

'delete the selection set
'ThisDrawing.SelectionSets.Item("TBLK2").Delete

End

End Sub

Private Sub UserForm_Activate()

UserForm1.ComboBox1.AddItem "AB 3x25x25"
UserForm1.ComboBox1.AddItem "AB 4x25x25"
UserForm1.ComboBox1.AddItem "AB 3x38x38"
UserForm1.ComboBox1.AddItem "AB 5x38x38"
UserForm1.ComboBox1.AddItem "AB 4x50x50"
UserForm1.ComboBox1.AddItem "AB 6x50x50"
UserForm1.ComboBox1.AddItem "AB 6x75x75"
UserForm1.ComboBox1.AddItem "AB 9x75x75"
UserForm1.ComboBox1.AddItem "AB 6x100x100"
UserForm1.ComboBox1.AddItem "AB 8x75x100"
UserForm1.ComboBox1.AddItem "AB 6x65x65"
UserForm1.ComboBox1.AddItem "ANCHOR BOX-50"
UserForm1.ComboBox1.AddItem "ANCHOR BOX-110"
UserForm1.ComboBox1.AddItem "BK-10"
UserForm1.ComboBox1.AddItem "BK-12R"
UserForm1.ComboBox1.AddItem "BS-001/SQ1"
UserForm1.ComboBox1.AddItem "BS-005/SQ2"
UserForm1.ComboBox1.AddItem "BS-007/SQ1"
UserForm1.ComboBox1.AddItem "BS-008"
UserForm1.ComboBox1.AddItem "BS-009"
UserForm1.ComboBox1.AddItem "BS-012"
UserForm1.ComboBox1.AddItem "BS-014/Q2"
UserForm1.ComboBox1.AddItem "BS-015/Q2"
UserForm1.ComboBox1.AddItem "BS-017"
UserForm1.ComboBox1.AddItem "CHERRY BLOSSOM-2"
UserForm1.ComboBox1.AddItem "CHERRY BLOSSOM"
UserForm1.ComboBox1.AddItem "CHERRY BLOSS-s"
UserForm1.ComboBox1.AddItem "CHERRY BLOSS-m"
UserForm1.ComboBox1.AddItem "CHERRY BLOSS-b"
UserForm1.ComboBox1.AddItem "COPPER WIRE 1"
UserForm1.ComboBox1.AddItem "COPPER WIRE 1.5"
UserForm1.ComboBox1.AddItem "COPPER WIRE 1.8"
UserForm1.ComboBox1.AddItem "COPPER SHT 0.1t"
UserForm1.ComboBox1.AddItem "COPPER SHT 0.2t"
UserForm1.ComboBox1.AddItem "COPPER SHT 0.8t"
UserForm1.ComboBox1.AddItem "CHECKERED PL t8"
UserForm1.ComboBox1.AddItem "CHECKERED PL t6"
UserForm1.ComboBox1.AddItem "CHECKERED PL t5"
UserForm1.ComboBox1.AddItem "CHECKERED PL t4"
UserForm1.ComboBox1.AddItem "CHECKERED PL t3"
UserForm1.ComboBox1.AddItem "CRS 12.7"
UserForm1.ComboBox1.AddItem "CRS 22"
UserForm1.ComboBox1.AddItem "CRS 25"
UserForm1.ComboBox1.AddItem "CRS 28.8"
UserForm1.ComboBox1.AddItem "CRS 32"
UserForm1.ComboBox1.AddItem "CRS 35"
UserForm1.ComboBox1.AddItem "CRS 40"
UserForm1.ComboBox1.AddItem "CRS 50"
UserForm1.ComboBox1.AddItem "CRS 60"
UserForm1.ComboBox1.AddItem "CRS 75"
UserForm1.ComboBox1.AddItem "CT-004"
UserForm1.ComboBox1.AddItem "DE-002"
UserForm1.ComboBox1.AddItem "DE-004"
UserForm1.ComboBox1.AddItem "DE-005/A"
UserForm1.ComboBox1.AddItem "DE-009"
UserForm1.ComboBox1.AddItem "DE-010S"
UserForm1.ComboBox1.AddItem "DE-010M"
UserForm1.ComboBox1.AddItem "DE-010B"
UserForm1.ComboBox1.AddItem "DE-013S"
UserForm1.ComboBox1.AddItem "DE-013 SET"
UserForm1.ComboBox1.AddItem "DE-014 SET"
UserForm1.ComboBox1.AddItem "DE-016"
UserForm1.ComboBox1.AddItem "DE-19"
UserForm1.ComboBox1.AddItem "DE-20"
UserForm1.ComboBox1.AddItem "DE-23"
UserForm1.ComboBox1.AddItem "DE-24"
UserForm1.ComboBox1.AddItem "DE-24-L-M"
UserForm1.ComboBox1.AddItem "DE-24-L-L"
UserForm1.ComboBox1.AddItem "DS-2008"
UserForm1.ComboBox1.AddItem "DS-2009"
UserForm1.ComboBox1.AddItem "DS-2014"
UserForm1.ComboBox1.AddItem "DS-2014-60A"
UserForm1.ComboBox1.AddItem "DS-2015"
UserForm1.ComboBox1.AddItem "DS-2051 (F-064)"
UserForm1.ComboBox1.AddItem "DS-2091 (F-014)"
UserForm1.ComboBox1.AddItem "DS-2114"
UserForm1.ComboBox1.AddItem "F-114"
UserForm1.ComboBox1.AddItem "FAB LEAF 039-04"
UserForm1.ComboBox1.AddItem "FAB GRAPE LEAF"
UserForm1.ComboBox1.AddItem "FM-3151"
UserForm1.ComboBox1.AddItem "FM-3152"
UserForm1.ComboBox1.AddItem "FM-3251"
UserForm1.ComboBox1.AddItem "FM-3284"
UserForm1.ComboBox1.AddItem "FM-4104W"
UserForm1.ComboBox1.AddItem "FM-4105W"
UserForm1.ComboBox1.AddItem "FM-5537"
UserForm1.ComboBox1.AddItem "FM-5538"
UserForm1.ComboBox1.AddItem "FM-5539"
UserForm1.ComboBox1.AddItem "FM-5540"
UserForm1.ComboBox1.AddItem "FT-H004 (handle)"
UserForm1.ComboBox1.AddItem "FHD-415"
UserForm1.ComboBox1.AddItem "FB 2x12"
UserForm1.ComboBox1.AddItem "FB 4x12"
UserForm1.ComboBox1.AddItem "FB 6x12"
UserForm1.ComboBox1.AddItem "FB 3x15"
UserForm1.ComboBox1.AddItem "FB 4x15"
UserForm1.ComboBox1.AddItem "FB 6x15"
UserForm1.ComboBox1.AddItem "FB 6x20"
UserForm1.ComboBox1.AddItem "FB 4x25"
UserForm1.ComboBox1.AddItem "FB 5x25"
UserForm1.ComboBox1.AddItem "FB 6x25"
UserForm1.ComboBox1.AddItem "FB 8x25"
UserForm1.ComboBox1.AddItem "FB 12x25"
UserForm1.ComboBox1.AddItem "FB 5x30"
UserForm1.ComboBox1.AddItem "FB 6x30"
UserForm1.ComboBox1.AddItem "FB 8x30"
UserForm1.ComboBox1.AddItem "FB 10x30"
UserForm1.ComboBox1.AddItem "FB 5x40"
UserForm1.ComboBox1.AddItem "FB 8x40"
UserForm1.ComboBox1.AddItem "FB 10x40"
UserForm1.ComboBox1.AddItem "FB 12x40"
UserForm1.ComboBox1.AddItem "FB 5x50"
UserForm1.ComboBox1.AddItem "FB 6X50"
UserForm1.ComboBox1.AddItem "FB 8x50"
UserForm1.ComboBox1.AddItem "FB 12x50"
UserForm1.ComboBox1.AddItem "FB 19 x 50"
UserForm1.ComboBox1.AddItem "FB 20 x 50"
UserForm1.ComboBox1.AddItem "FB 25 x 50"
UserForm1.ComboBox1.AddItem "FB 8x60"
UserForm1.ComboBox1.AddItem "FB 12x60"
UserForm1.ComboBox1.AddItem "FB 4x75"
UserForm1.ComboBox1.AddItem "FB 6x75"
UserForm1.ComboBox1.AddItem "FB 8X75"
UserForm1.ComboBox1.AddItem "FB 11x75"
UserForm1.ComboBox1.AddItem "FB 12X75"
UserForm1.ComboBox1.AddItem "FB 6x100"
UserForm1.ComboBox1.AddItem "GB 1470"
UserForm1.ComboBox1.AddItem "GB1471"
UserForm1.ComboBox1.AddItem "GB 2103"
UserForm1.ComboBox1.AddItem "GB 2104"
UserForm1.ComboBox1.AddItem "GB 2105 / OI"
UserForm1.ComboBox1.AddItem "GB 2106 / OI"
UserForm1.ComboBox1.AddItem "GB 2110"
UserForm1.ComboBox1.AddItem "GEKIDAN GRAPES"
UserForm1.ComboBox1.AddItem "GF CSO120"
UserForm1.ComboBox1.AddItem "GF CSO140"
UserForm1.ComboBox1.AddItem "GF CS200"
UserForm1.ComboBox1.AddItem "GF CSO250"
UserForm1.ComboBox1.AddItem "GB 2424"
UserForm1.ComboBox1.AddItem "GB 2475 W"
UserForm1.ComboBox1.AddItem "GB 2486 W"
UserForm1.ComboBox1.AddItem "GB 2491"
UserForm1.ComboBox1.AddItem "GB 2492"
UserForm1.ComboBox1.AddItem "GI SHEET #20"
UserForm1.ComboBox1.AddItem "GI WIRE #16"
UserForm1.ComboBox1.AddItem "H-BEAM100X100(t8)"
UserForm1.ComboBox1.AddItem "H-BEAM150X250"
UserForm1.ComboBox1.AddItem "H-BEAM 125X125"
UserForm1.ComboBox1.AddItem "H-BEAM 150X150"
UserForm1.ComboBox1.AddItem "H-BEAM 200X200"
UserForm1.ComboBox1.AddItem "HIBISCUS LEAF"
UserForm1.ComboBox1.AddItem "HIBISCUS FLOWER"
UserForm1.ComboBox1.AddItem "MSP t1.0"
UserForm1.ComboBox1.AddItem "MSP t1.5"
UserForm1.ComboBox1.AddItem "MSP t2"
UserForm1.ComboBox1.AddItem "MSP t2.5"
UserForm1.ComboBox1.AddItem "MSP t3"
UserForm1.ComboBox1.AddItem "MSP t4"
UserForm1.ComboBox1.AddItem "MSP t5"
UserForm1.ComboBox1.AddItem "MSP t6"
UserForm1.ComboBox1.AddItem "MSP t8"
UserForm1.ComboBox1.AddItem "MSP t9"
UserForm1.ComboBox1.AddItem "MSP t10"
UserForm1.ComboBox1.AddItem "MSP t12"
UserForm1.ComboBox1.AddItem "MSP t16"
UserForm1.ComboBox1.AddItem "MSP t20"
UserForm1.ComboBox1.AddItem "MSP t25"
UserForm1.ComboBox1.AddItem "MSP t30"
UserForm1.ComboBox1.AddItem "NEWSPRINT PAPER"
UserForm1.ComboBox1.AddItem "OI-EMO HINGES 12"
UserForm1.ComboBox1.AddItem "OI-HINGES 144"
UserForm1.ComboBox1.AddItem "OI-HINGES 30x144"
UserForm1.ComboBox1.AddItem "OI-HINGE 32x191"
UserForm1.ComboBox1.AddItem "OI-HINGE 50x191"
UserForm1.ComboBox1.AddItem "OI-FOOT BOLT/SK"
UserForm1.ComboBox1.AddItem "OI-BARREL & BOLT"
UserForm1.ComboBox1.AddItem "OI-STOPPER"
UserForm1.ComboBox1.AddItem "ONDA LOCK"
UserForm1.ComboBox1.AddItem "OLIVE FRUIT-20"
UserForm1.ComboBox1.AddItem "OLIVE FRUIT-30"
UserForm1.ComboBox1.AddItem "OLIVE FRUIT-40"
UserForm1.ComboBox1.AddItem "OLIVE

First off, UserForm1 denotes that you are using VBA and NOT vb6.0 so in the future you might want to search out VBA forums...

Second off, you could use a loop or two to cut down on the amount of code you have...


I have a few more comments but will leave them to those that are more experienced with VBA but I will say that I did not see where you set the variable Tatts equal to the controls it is to be associated with...


Good Luck

Oh, im sorry i didnt tell you that i made it inside the AutoCAD VBA and it is working fine inside AutoCAD, but this is my idea, iwant it to run stand alone that is why i exported it and open it to VB6.0 and modify some, sorry for mis info.

Thanks

i really need it to run stand alone, i cant understand why im always getting error at Tatts..

As I said, I don't see where you set tatts = to anything. In VB6.0, you can turn all of your text boxes into an array of controls and I mention this because that looks like what you are doing. In VBA and VB you could do something like...

Dim C() As Control
Redim C(0) As Control
Set C(0) = Text1
ReDim Preserve C(1) As Control
Set C(1) = Text2
'and so on

and it is this, that I do not see you do. I don't see where you set tatts = control... thus I believe your error...

Good Luck

I think your error is generated because you are trying to change an Integer value into a string -

Sub UpdateAttrib(TagNumber As Integer, BTextString As String)


'And then -

Tatts(TagNumber).TextString = BTextString

If BTextstring is NOT a number you will most definitely get an error.
Also as vb5 said, you have not declared a type for Tatts. Your code does not know what to do with 'Tatts', thus generating an error.

Rather try and change 'Tagnumber as integer' to 'Tagnumber as string' and see if it helps.

This question has already been answered. Start a new discussion instead.