Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
changing image on interface at runtime
Old
  (#1)
werewolfie
Guest
 
Posts: n/a
Default changing image on interface at runtime - 06-04-2007, 08:50 AM

Hi Group

I'm kind of new to vb6 so forgive me any stupid questions

I'm writing a little program that has a picture on it.
I want to change the picture with this sub

Private Sub Picture1_Click()

For i = 1 To 10

If i >= 10 Then i = 1
LoadImage (i)
next i
End If
End Sub

Q 1: how do i declare 'i' as variable ?
Q 2: i get a compile error with LoadImage, saying
'argument not optional'

can or can't i use loadimage for this or should i think of using OLE or
something else

i've been searching everywhere from msdn to ms learn visual basic 6 but
can't find it.

Thanks

Jos


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: changing image on interface at runtime
Old
  (#2)
Randy Birch
Guest
 
Posts: n/a
Default Re: changing image on interface at runtime - 06-04-2007, 08:50 AM

LoadImage is an API, defined as:

HANDLE LoadImage(
HINSTANCE hinst, // handle to instance
LPCTSTR lpszName, // image to load
UINT uType, // image type
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load options
);


Methinks you want LoadPicture, a VB method, that loads an image from a
file...

Private Sub Picture1_Click()

static cnt as long
cnt=cnt+1
If cnt > 10 Then cnt = 1
Picture1.Picture=LoadPicture(somefilearrayofpictur es(cnt))
End If

End Sub

.... where somefilearrayofpictures() is a string array defining the files to
load, ie

'form general declarations
dim somefilearrayofpictures(1 to 10) as string

sub form_load

somefilearrayofpictures(1) = "c:\windows\somepix.bmp"
somefilearrayofpictures(2) = "c:\some\place\else\anotherpix.gif"
.... etc

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.


"werewolfie" <EMAIL REMOVED> wrote in message
news:3fc0d01e$0$15520$EMAIL REMOVED4al l.nl...
: Hi Group
:
: I'm kind of new to vb6 so forgive me any stupid questions
:
: I'm writing a little program that has a picture on it.
: I want to change the picture with this sub
:
: Private Sub Picture1_Click()
:
: For i = 1 To 10
:
: If i >= 10 Then i = 1
: LoadImage (i)
: next i
: End If
: End Sub
:
: Q 1: how do i declare 'i' as variable ?
: Q 2: i get a compile error with LoadImage, saying
: 'argument not optional'
:
: can or can't i use loadimage for this or should i think of using OLE or
: something else
:
: i've been searching everywhere from msdn to ms learn visual basic 6 but
: can't find it.
:
: Thanks
:
: Jos
:
:


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: changing image on interface at runtime
Old
  (#3)
werewolfie
Guest
 
Posts: n/a
Default Re: changing image on interface at runtime - 06-04-2007, 08:51 AM

Thanks for your help Larry, but the next problem is another compile error in
this part of the code:

Private Sub Picture1_Click()

static cnt as long
cnt=cnt+1
If cnt > 10 Then cnt = 1
Picture1.Picture=LoadPicture somefilearrayofpictures(cnt))
End If

End Sub

i implemented your code in my program, but now when i compile it, it says
'If without Block End If'

i am running vb6 on win2k sp4

Do you know what this compile error could mean?

Thanks

Jos

"Randy Birch" <EMAIL REMOVED> schreef in bericht
news:Ur4wb.7431$EMAIL REMOVED e.rogers.com...
> LoadImage is an API, defined as:
>
> HANDLE LoadImage(
> HINSTANCE hinst, // handle to instance
> LPCTSTR lpszName, // image to load
> UINT uType, // image type
> int cxDesired, // desired width
> int cyDesired, // desired height
> UINT fuLoad // load options
> );
>
>
> Methinks you want LoadPicture, a VB method, that loads an image from a
> file...
>
> Private Sub Picture1_Click()
>
> static cnt as long
> cnt=cnt+1
> If cnt > 10 Then cnt = 1
> Picture1.Picture=LoadPicture(somefilearrayofpictur es(cnt))
> End If
>
> End Sub
>
> ... where somefilearrayofpictures() is a string array defining the files

to
> load, ie
>
> 'form general declarations
> dim somefilearrayofpictures(1 to 10) as string
>
> sub form_load
>
> somefilearrayofpictures(1) = "c:\windows\somepix.bmp"
> somefilearrayofpictures(2) = "c:\some\place\else\anotherpix.gif"
> ... etc
>
> --
>
> Randy Birch
> MVP Visual Basic
> http://www.mvps.org/vbnet/
> Please respond only to the newsgroups so all can benefit.
>
>
> "werewolfie" <EMAIL REMOVED> wrote in message
> news:3fc0d01e$0$15520$EMAIL REMOVED4al l.nl...
> : Hi Group
> :
> : I'm kind of new to vb6 so forgive me any stupid questions
> :
> : I'm writing a little program that has a picture on it.
> : I want to change the picture with this sub
> :
> : Private Sub Picture1_Click()
> :
> : For i = 1 To 10
> :
> : If i >= 10 Then i = 1
> : LoadImage (i)
> : next i
> : End If
> : End Sub
> :
> : Q 1: how do i declare 'i' as variable ?
> : Q 2: i get a compile error with LoadImage, saying
> : 'argument not optional'
> :
> : can or can't i use loadimage for this or should i think of using OLE or
> : something else
> :
> : i've been searching everywhere from msdn to ms learn visual basic 6 but
> : can't find it.
> :
> : Thanks
> :
> : Jos
> :
> :
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: changing image on interface at runtime
Old
  (#4)
werewolfie
Guest
 
Posts: n/a
Default Re: changing image on interface at runtime - 06-04-2007, 08:51 AM

Thanks for your help Randy, but the next problem is another compile error in
this part of the code:

Private Sub Picture1_Click()

static cnt as long
cnt=cnt+1
If cnt > 10 Then cnt = 1
Picture1.Picture=LoadPicture somefilearrayofpictures(cnt))
End If

End Sub

i implemented your code in my program, but now when i compile it, it says
'End If without Block If'

i am running vb6 on win2k sp4

Do you know what this compile error could mean?

Thanks

Jos


"Randy Birch" <EMAIL REMOVED> schreef in bericht
news:Ur4wb.7431$EMAIL REMOVED e.rogers.com...
> LoadImage is an API, defined as:
>
> HANDLE LoadImage(
> HINSTANCE hinst, // handle to instance
> LPCTSTR lpszName, // image to load
> UINT uType, // image type
> int cxDesired, // desired width
> int cyDesired, // desired height
> UINT fuLoad // load options
> );
>
>
> Methinks you want LoadPicture, a VB method, that loads an image from a
> file...
>
> Private Sub Picture1_Click()
>
> static cnt as long
> cnt=cnt+1
> If cnt > 10 Then cnt = 1
> Picture1.Picture=LoadPicture(somefilearrayofpictur es(cnt))
> End If
>
> End Sub
>
> ... where somefilearrayofpictures() is a string array defining the files

to
> load, ie
>
> 'form general declarations
> dim somefilearrayofpictures(1 to 10) as string
>
> sub form_load
>
> somefilearrayofpictures(1) = "c:\windows\somepix.bmp"
> somefilearrayofpictures(2) = "c:\some\place\else\anotherpix.gif"
> ... etc
>
> --
>
> Randy Birch
> MVP Visual Basic
> http://www.mvps.org/vbnet/
> Please respond only to the newsgroups so all can benefit.
>
>
> "werewolfie" <EMAIL REMOVED> wrote in message
> news:3fc0d01e$0$15520$EMAIL REMOVED4al l.nl...
> : Hi Group
> :
> : I'm kind of new to vb6 so forgive me any stupid questions
> :
> : I'm writing a little program that has a picture on it.
> : I want to change the picture with this sub
> :
> : Private Sub Picture1_Click()
> :
> : For i = 1 To 10
> :
> : If i >= 10 Then i = 1
> : LoadImage (i)
> : next i
> : End If
> : End Sub
> :
> : Q 1: how do i declare 'i' as variable ?
> : Q 2: i get a compile error with LoadImage, saying
> : 'argument not optional'
> :
> : can or can't i use loadimage for this or should i think of using OLE or
> : something else
> :
> : i've been searching everywhere from msdn to ms learn visual basic 6 but
> : can't find it.
> :
> : Thanks
> :
> : Jos
> :
> :
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: changing image on interface at runtime
Old
  (#5)
Geoff Turner
Guest
 
Posts: n/a
Default Re: changing image on interface at runtime - 06-04-2007, 08:51 AM


"werewolfie" <EMAIL REMOVED> wrote in message
news:3fc1b2e5$0$20464$EMAIL REMOVED4a ll.nl...
> Thanks for your help Randy, but the next problem is another compile error

in
> this part of the code:
>
> Private Sub Picture1_Click()
>
> static cnt as long
> cnt=cnt+1
> If cnt > 10 Then cnt = 1

Line above ***umes an END IF statement at end

> Picture1.Picture=LoadPicture somefilearrayofpictures(cnt))

You'r missing a parenthesis in the above line

> End If

....therefore this END IF don't have an IF part
Try:
Private Sub Picture1_Click()

static cnt as long
cnt=cnt+1
If cnt > 10 Then
cnt = 1
Picture1.Picture=LoadPicture (somefilearrayofpictures(cnt))
End Sub

> i implemented your code in my program, but now when i compile it, it says
> 'End If without Block If'
>
> i am running vb6 on win2k sp4
>
> Do you know what this compile error could mean?
>
> Thanks
>
> Jos



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: changing image on interface at runtime
Old
  (#6)
werewolfie
Guest
 
Posts: n/a
Default Re: changing image on interface at runtime - 06-04-2007, 08:51 AM

Thanks for your help. the program works now


"Geoff Turner" <EMAIL REMOVED> schreef in bericht
news:bpt0b9$EMAIL REMOVED...
>
> "werewolfie" <EMAIL REMOVED> wrote in message
> news:3fc1b2e5$0$20464$EMAIL REMOVED4a ll.nl...
> > Thanks for your help Randy, but the next problem is another compile

error
> in
> > this part of the code:
> >
> > Private Sub Picture1_Click()
> >
> > static cnt as long
> > cnt=cnt+1
> > If cnt > 10 Then cnt = 1

> Line above ***umes an END IF statement at end
>
> > Picture1.Picture=LoadPicture somefilearrayofpictures(cnt))

> You'r missing a parenthesis in the above line
>
> > End If

> ...therefore this END IF don't have an IF part
> Try:
> Private Sub Picture1_Click()
>
> static cnt as long
> cnt=cnt+1
> If cnt > 10 Then
> cnt = 1
> Picture1.Picture=LoadPicture (somefilearrayofpictures(cnt))
> End Sub
>
> > i implemented your code in my program, but now when i compile it, it

says
> > 'End If without Block If'
> >
> > i am running vb6 on win2k sp4
> >
> > Do you know what this compile error could mean?
> >
> > Thanks
> >
> > Jos

>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top