AutoCAD 2012 and VBA Text not appearing in textbox

AutoCAD 2012 and VBA Text not appearing in textbox

cadprof
Enthusiast Enthusiast
4,533 Views
6 Replies
Message 1 of 7

AutoCAD 2012 and VBA Text not appearing in textbox

cadprof
Enthusiast
Enthusiast

AutoCAD 2012 is loaded on my office machine with WIndows 7 64 bit.  I have downloaded the correct vba module and installed.  After writing a simple program with two texboxes for user input and a calculation button with an answer box,  when running the cursor appears in the textbox but neither textbox will  accept input from the keyboard and the cursor does not move nor does the tab key work even with it set in the program.  Pressing the calculate button and a zero appears.  Any help would be deeply appreciated. In the toolbox I have added the AcFocusCtrl control, still no luck.

 

Thanks,

Cadprof

0 Likes
Accepted solutions (2)
4,534 Views
6 Replies
Replies (6)
Message 2 of 7

truss_85
Advocate
Advocate

Can you possible to send code?

It is more faster to get answer and more easier to us who want to help.

 

Best Regards.

0 Likes
Message 3 of 7

cadprof
Enthusiast
Enthusiast
Accepted solution

I teach the very basics of coding with VBA in AutoCAD , so the following code is for one button to calculate and place an answer in the Anstxt textbox.  When I run the program and try to type in a length or width, nothing appears in the textbox.  I have added the AcFocusCtrl control, but nothing happens.  Do you know of any problems with the VBA enabler and AutoCAD 2012?  I am running WIndows 7 Professional.  Also I noticed that when I click on a textbox to type in a number and then click the second box, I can see the cursor moving in AutoCAD.  When I click again on the program it regains control of the cursor.

 

Thanks for the help.

 

Private Sub CommandButton1_Click()
    AnsTxt.Text = (Val(LenTxt.Text) * (Val(WidthTxt.Text)))
End Sub

Private Sub Label2_Click()

End Sub

 

First-Proj.jpg

Message 4 of 7

norman.yuan
Mentor
Mentor
Accepted solution

Still teaching VBA for AutoCAD? Autodesk has been signalling the death of VBA in AutoCAD since ACAD2010 and 64-bit AutoCAD has been proving VBA in 64-bit Acad has not much practical use value. One who is learning VBA for AutoCAD now would soon find him/her wasting time on this.

 

Anyway, what you described is typical with 64-bit Acad VBA in a Win7 box: in a modal user form, mouse cursor can be put into a text box, but key stroke will not enter anything into it; a command button needs to be clicked twice to activate the code in CommandButton_Click().

 

In general adding an acFocusCtrl to the form solves the problem. In your case, you did mention that you added acFocsCtrl and it stil did not work. However, in the Userform picture you attached, I do not see there is an acFocusCtrl.

 

See my UserForm picture here:

 

UserForm.png

 

Before I drop the acFocusCtrl on the form, I cannot type into TextBox and need to click twice on a button. After drop the acFocsCtrl, the UserForm works as expected.

 

IMO, even VBA form works with the help of acFocusCtrl, it is definitely not worth investing time/money to learn Acad VBA.

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 7

truss_85
Advocate
Advocate

Reason is, that there is no VBA for 64bit available from Microsoft, they did it just for 32bit and say if you have 64bit change to .NET platform and that's it.

 

Autodesk did a trick to have it at least working, the create a separate 32bit-process doing the VBA-job and from 64bit-AutoCAD it sends all traffic through the operating-system to the 32bit-VBA, and every request from the VBA-process to any AutoCAD-geometry/variables/properties.... are also sent from the 32bit-process via operating-system to AutoCAD.

 

Even if Microsoft Forms 2.0 Object Library is checked it won't work.

 

There will always be a lot of problem with vba in 64 bit. I suggest you to change to .NET platform like I do.

 

I also try code in 32 bit system it will work.

 

Best Regards...

 

0 Likes
Message 6 of 7

truss_85
Advocate
Advocate

I did not see the message.

BTW I agree with you.

There is a solution with this but in 64 bit vba full of cracks..

0 Likes
Message 7 of 7

cadprof
Enthusiast
Enthusiast

es, I agree about VBA and AutoCAD but until we get our major curriculum change through, I am required to follow the abstract, so hopefully next time arounf (Spring of 2013) things will change.

 

Thank you all for the replies and help.

 

Cadprof

0 Likes