473,383 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Replacing bmps in a Picturebox

2
Hello,
I'm relatively new to VB and I'm having trouble with some (what should be simple) code. This code is just me, trying to teach myself ways to do things, and maybe there'll be a practical application in the future. I'm using VB 6.0 on a Windows XP platform.

Ok, the code is:
Option Explicit
Dim inc As Integer

Sub form_load()
Dim objPics(1 To 7) As String
' Load bitmaps into the Picture object array.
objPics(1) = "C:\VBstuff\test\pic1.bmp"
objPics(2) = "C:\VBstuff\test\pic2.bmp"
objPics(3) = "C:\VBstuff\test\pic3.bmp"
objPics(4) = "C:\VBstuff\test\pic4.bmp"
objPics(5) = "C:\VBstuff\test\pic5.bmp"
objPics(6) = "C:\VBstuff\test\pic6.bmp"
objPics(7) = "C:\VBstuff\test\pic7.bmp"

Timer1.Enabled = True

End Sub


Private Sub Timer1_Timer()
inc = 1
If inc < 3 Then
Picture1.Picture = LoadPicture(objPics(inc))
inc = inc + 1
Else
Timer1.Enabled = False
End If
End Sub

What I get is:
Compile Error
Sub or Function not defined

Picture1.Picture = LoadPicture(objPics(inc))
objPics gets highlighted.

How can I get it to see that it's an array and not a function?

Thanks in advance,
Mark
Nov 14 '07 #1
2 1050
YarrOfDoom
1,247 Expert 1GB
I don't know VB6, but in Visual Studio 2005 Express, the lower boundery of an arry should always be 0, making your declaration:
Expand|Select|Wrap|Line Numbers
  1. Dim objPics(0 To 6) As String
Or maybe you typed the arrayname wrong somewhere in your code. If it isn't that, then your error is "VB6-only", and I hope someone else will be able to solve it for you.
Or maybe you can try using a string to where you load your value if you need it:
Expand|Select|Wrap|Line Numbers
  1. string = objPics(inc)
  2. Picture1.Picture = LoadPicture(string)
Yarr
(ps: using [code]-tags makes your code more readable to others)
Nov 14 '07 #2
SonnyH
7
You should declare objPics(1 To 7) outside of Sub Form_Load because in your code, that array is local Sub Form_Load only.

Also statement inc = 1 should not be in Timer sub
Nov 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: SamSpade | last post by:
I have a usercontrol that contains a picturebox. The user can obtain (creategraphics) a picturebox graphics object and draw on the picturebox. She could do gr.GraphincInit.Millimeter and then draw...
0
by: akh | last post by:
I want to use de Drag and Drop ´s event to move a picture box from a form and within a Picture Box. But I have behaviour if the MyPBox As PictureBox as the Globale varible or not Thanks for...
3
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
2
by: Craig | last post by:
Hi there, I'm trying to open colour BMPs using PIL and I'm getting the following errors. Opening a 16 colour BMP I get: Traceback (most recent call last): File "<pyshell#3>", line 1, in...
4
by: munibe | last post by:
Hi, i have a problem about picturebox control. if you may help me, i will be so happy. i have a picturebox named pic_map, and i added a button named customer_button, my wish is to add a new small...
3
by: kirk | last post by:
I have a form with a PictureBox control on it. The .Image property is set to a PNG file(which shows the picture of the US map) with some transparency in it. The .BackColor property is set to...
2
by: DumRat | last post by:
Hi, I want to run an animation(in essence). I want to draw multiple images (possibly .bmps, but I'd like other formats as well.) on to the screen each frame. I tried to do this with some C++...
5
by: AWW | last post by:
XP VB 2005 running an example from help that creates a picturebox in code - the picturebox is not created. If I comment out the "Dim Box as New PictureBox" and create it in Design mode - the...
17
by: mrcw | last post by:
private void timer1_Tick(object sender, EventArgs e) { Bitmap m_Undo = new Bitmap(pbLeftWebcam.Image); if (Invert(m_Undo)) ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.