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

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

Still cant get

Sorry i am very new.

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.

WOW thanks it works now..thank you thank you thank you!

Only a pleasure. Please mark as read if solved.

I am getting run time error while run the program............ while i m selecting 'w' in combobox then error comes...

kinldy help ............

Private Sub Combo6_Click()

Text1.Text = Text1.Text + 1

Text9.Text = Val(Text9.Text) + Val(Combo6.Text)
Combo7.Enabled = True
If Combo6.Text = w Then
Text7.Text = Text7.Text + 1
Else
If Combo6.Text = 4 Then (run time error -13)
Text12.Text = Text12.Text + 1

Else
If Combo6.Text = 6 Then
Text11.Text = Text11.Text + 1

End If
End If
End If
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.