Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Image in vba form

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
Demasure1
2262 Views, 12 Replies

Image in vba form

Hello,

 

I have a vba program. But when i change my optionbutton the picture next to it need to change.

 

Look ad my attachment:

When in the green box i change the button, the optionbutton needs to change also.

 

the code i use is:

      Private Sub optDSLiBo_Click()
       If frmAlgemeen.optDSLiBo = True Then
          InsertPicture "C:\Autocad\Afbeeldingen Vba Programma\Hoekverbindingen\LinksBovenStijl.bmp"
       End If
     End Sub

 

but i get a error on the this line: "InsertPicture "C:\Autocad\Afbeeldingen Vba Programma\Hoekverbindingen\LinksBovenStijl.bmp""

 

Does somebody know the answer? 

 

thank you 

 

12 REPLIES 12
Message 2 of 13
Alfred.NESWADBA
in reply to: Demasure1

Hi,

 

INSERTPICTURE is nothing I know from VBA, if you have a routine (Sub or Function) with that name it's up to you to correct or to show it.

 

>> but i get a error on the this line:

And the error message is ...?

 

- alfred -

PS: there is a separate forum for VBA on AutoCAD >>>there<<<.

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 13
Demasure1
in reply to: Alfred.NESWADBA

The error i have is :

" Compile error:

Sub or function not defined"

 

The code i have added in previous message is all i have.

I have no sub or routine for a image.

 

How does this work?

Message 4 of 13
Alfred.NESWADBA
in reply to: Demasure1

Hi,

 

>> Sub or function not defined

That's the answer, there is no Sub or Function available with name "INSERTPICTURE", so you can't call anything that does not exist.

 

So where did you find the function-name "INSERTPICTURE" as valid function/sub? Any help file? Or a code in internet? From there you will have to find out what's inside the function/sub.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 13
Demasure1
in reply to: Alfred.NESWADBA

hi

 

i found that code on the internet. 

i inserted the code into my vba program and changed it to my file.

 

Met i got the compile error..

I don't need a sub for inserting a image.

I need the image in my userform, When i activate a other button in my userform the picture next to it should change to.

 

 I don't need the image in autocad, only in my userform.

so i tried to do this with a if function

 

is this the wrong way? 

 

thanks

Message 6 of 13
hwalker
in reply to: Demasure1

Try this

 

If Optionbutton1.Enabled=True then

 

Myformname.Picture="The Path to picture 1"

 

ElseIf Optionbutton2.Enabled=True then

 

Myformname.Picture="The Path to picture 2"

 

ElseIf Optionbutton3.Enabled=True then

 

Myformname.Picture="The Path to picture 3"

 

EndIf

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

Message 7 of 13
Demasure1
in reply to: hwalker

hi,

 

What i the path Smiley Frustrated

 

 is the path: "("C:\Autocad\Afbeeldingen Vba Programma\Hoekverbindingen\LinksBovenRegel.bmp")"?

 

i get next error:

 

Object required.

 

thanks ! 

 

 

Message 8 of 13
hwalker
in reply to: Demasure1

Just found what I missed out you need Mypicturebox.Picture = Loadpicture("C:\Autocad\Afbeeldingen Vba Programma\Hoekverbindingen\LinksBovenRegel.bmp")

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

Message 9 of 13
Demasure1
in reply to: hwalker

We are close but i still get next error:

"run-time error

object required"

 

strange ... 

 

Message 10 of 13
hwalker
in reply to: Demasure1

Run the program using the source code. When you get the run-time error copy and paste the text which is highlighted here.

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

Message 11 of 13
Demasure1
in reply to: hwalker

is this what you mean?

 

I send you a printscreen of my screen with error and help.

 

Sorry i am still learning vba.

 

 

Message 12 of 13
hwalker
in reply to: Demasure1

That's alright. Sorry but I have to giggle now as I've seen what your problem is.

 

You have put in MYPICTUREBOX when in fact it should be the name of your control eg cmdcancel.Picture =LoadPicture etc.

 

You need to find out what the name of the control where you put the image is called. Looking at your screen shot it might be along the lines of IMAGE1 substitute whatever that control is called for MYPICTUREBOX

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

Message 13 of 13
Demasure1
in reply to: hwalker

Its solved 🙂

 

 You solved my problem:

If frmAlgemeen.optDRLiBo = True Then
Image12.Picture = LoadPicture("C:\Autocad\Afbeeldingen Vba Programma\Hoekverbindingen\Gif\BovenDoorlopend.gif")
End If

 

Oh thank you !!!! 😄 

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

Post to forums  

Autodesk Design & Make Report

”Boost