VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert module in form

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Demasure1
385 Views, 6 Replies

Insert module in form

Hello,

 

I have made 4 modules i want to insert in my form.

 

The code i use to insert is : 

 

If chkCoAlgemeen = True Then
Call Mod_VAZAlgemeen
End If

 

But when i test my program nothing happens. No errors.

Ill send a printscreen of my programcodes

 

Hope somebody can help me 

 

thanks

6 REPLIES 6
Message 2 of 7
RICVBA
in reply to: Demasure1

with so few elements I can only guess that either "Mod_VAZAlgemeen" module is not present anywhere in your project or it's defined as "private" so that the Form's code cannot access it. but in this latter case I'd expect a "compiling error" when debugging or running the program

 

I could help you more if you'd post your entire code

 

bye

Message 3 of 7
Demasure1
in reply to: RICVBA

Ill send you my codes of Commandbutton and module:

 

Commandbutton:

 

Private Sub cmdTeken_Click()

 

'Subprogramma's insert
'----------------------------------------------
If chkCoAlgemeen = True Then
Call Mod_VAZAlgemeen
End If

 

Module: 

Sub Mod_VAZAlgemeen()


'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
'*****INVOEGEN CORPUS DOORLOPENDE STIJLEN*****
'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
If optDoorStijl And chkVooraanzicht = True Then
'--------------------------------------
'Vooraanzicht Doorlopende Stijlen
'--------------------------------------

dblInvoegpunt(0) = 0: dblInvoegpunt(1) = 0: dblInvoegpunt(2) = 0
Set objBlok1 = ThisDrawing.ModelSpace.InsertBlock(dblInvoegpunt, "C:\Autocad\Definitieve blocks\1.Onderkast\1.Vooraanzichten\Niet Beplakt\Vooraanzicht.NB.Doorlopende Stijlen.dwg", 1#, 1#, 1#, 0#)
If objBlok1.IsDynamicBlock Then
oprops = objBlok1.GetDynamicBlockProperties
For i = 0 To UBound(oprops)
Set oDblkProp = oprops(i)
If oDblkProp.PropertyName = "Hoogte" Then
oDblkProp.Value = HoogteKast
Exit For
End If
Next

frmKast.hide
End If

End Sub

 

Is this what you need? 

 

Message 4 of 7
RICVBA
in reply to: Demasure1

from what you posted I can only argue that "chkCoAlgemeen" variable is not set anywhere so that the check "If chkCoAlgemeen = True" results "false" and nothing happens.

maybe your purpose is referencing a variabile named "chkCoAlgemeen" which is set in a different module other than the form's code. in this case you should declare as "Public" at the very top of any module of your choice

 

in any case I'd suggest you always use "option Explicit" at the very top of every module and form, so that while debugging you're warned about undeclared variables which otherwise wolud be taken as of "variant" type, assigned its default value and processed as such

 

for best helping you, please attach your dvb file

 

note: the code you wrote in your post is missing and "End If" at the bottom

 

Message 5 of 7
Demasure1
in reply to: RICVBA

Ill send you my whole program.

 

its my 3 week i am using Vba. And i am not so good with it. 

I hope you can help me and find my problem.

But i think if you run the program it will not work because you don't have the blocks.

i added like 100 blocks or more

 

Message 6 of 7
RICVBA
in reply to: Demasure1

the problem was of the type I guessed.

the frmKast form code worked well and actually succeded in call Mod_VAZAlgemeen(), but once the program flow gets into this module it finds what you meant would be references to that form objects (optionbuttons, checkboxes, ...) but without any form reference specification and thus resulting in not declared variables with module scope and "empty" values

 

the solution is to insert proper reference to your form when you have to deal with its objects.

for instance

If optDoorStijl And chkVooraanzicht = True Then

 has to become

If frmKast.optDoorStijl And frmKast.chkVooraanzicht Then

and you must do this in every module for every reference to your form's objects.

 

Had you used "Option Explicit" at the very top of every module you'd have received warnings at compilation time for each and every missing variables definitions.

I'd recommend you do that now so that it can both help you finding all those form's references to correct and possibly other different undefined variables

 

note: in that latter code snippet of mine I also used what i consider a more proper format for multiple checking condition. yours would work too in this case, but I think it could possibly lead you to some errors in more complex cases

 

bye

 

Message 7 of 7
Demasure1
in reply to: RICVBA

thank you !

its working now 😄 😄

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost