|
-
Jan 27th, 2006, 04:14 AM
#1
[RESOLVED] Problem with Arry's.
Hi All,
I've tryed to create some arrays, but it didn't worked.
That's my array for my PictureBoxes:
VB Code:
Dim arr As PictureBox() = {PictureBox1, PictureBox2, PictureBox3}
It gave me the error : Name 'PictureBox2' is not declared.
Name 'PictureBox3' is not declared.
What I'm doing wrong here!
Read also from the beginning because I'm still trying to create.
Thanks in advance,
sparrow1
-
Jan 27th, 2006, 04:17 AM
#2
Re: Problem with Arry's.
You would have to have created the PictureBoxes themselves in the designer first.
-
Jan 27th, 2006, 04:40 AM
#3
Re: Problem with Arry's.
Hi jmc,
That wasn't the intention to create several PictureBoxes in the designer.
It's for a calculation app.
I want just one PictureBox and the possibility to load several Pictures in it.
After I loaded a Picture I want to controle it.
Example: I have a Picture with 5 cars then the user has to put 5 into a textBox.
If the answer is correct then Next Picture.....
That's why I thougth to use an Array.
-
Jan 27th, 2006, 05:56 AM
#4
Re: Problem with Arry's.
In that case you just need to create an array that CAN hold a certain number of PictureBoxes. The way you have done it you are trying to initialise the array as well. If you want an array that can hold 5 PictureBoxes then declare the variable and create the array but do not initialise it:Note that without specifying the upper bound you are simply creating a variable of type PictureBox(). By specifying the upper bound the actual array object will be created with enough room to hold the number of objects that you specify. Each element is basically a variable of type PictureBox, but there are no PictureBox objects at this stage. Remember that .NET arrays are reference type objects, i.e. instances of the Array class.
-
Jan 27th, 2006, 05:58 AM
#5
Re: Problem with Arry's.
Reading what you wrote again, are you sure that you aren't confusing a PictureBox with an Image? A PictureBox is a control in which you can display an Image. If you're only displaying one image at a time then you should only need one PictureBox and simply change its Image property.
-
Jan 27th, 2006, 06:29 AM
#6
Re: Problem with Arry's.
 Originally Posted by jmcilhinney
Reading what you wrote again, are you sure that you aren't confusing a PictureBox with an Image? A PictureBox is a control in which you can display an Image. If you're only displaying one image at a time then you should only need one PictureBox and simply change its Image property.
Yes I know how to display an Image into a PictureBox, but how can I control each picture then into my TextBox.
-
Jan 27th, 2006, 06:51 AM
#7
Re: Problem with Arry's.
 Originally Posted by sparrow1
Yes I know how to display an Image into a PictureBox, but how can I control each picture then into my TextBox.
I'm afriad I don't really know what you mean.
-
Jan 28th, 2006, 04:35 AM
#8
Re: Problem with Arry's.
 Originally Posted by jmcilhinney
I'm afriad I don't really know what you mean.
Hi jmc,
It could be that I made it to difficult to explain, but like I wrote in the beginning of this thread, I wanted to control an Image!
But anyway, I found it!!!!
I know there are other ways to do it, but it works for me!
Here's my code:
VB Code:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim arr(2) As PictureBox
Button2.Visible = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ChangeImage()
Button2.Visible = True
End Sub
Private Sub ChangeImage()
Static Dim iImage As Integer
Select Case iImage
Case 0
PictureBox.Visible = True
PictureBox.Image = Image.FromFile(Application.StartupPath & "\Image\blablabla.jpg")
TextBox1.Focus()
Button1.Visible = False
iImage += 1
Case 1
PictureBox.Visible = True
PictureBox.Image = Image.FromFile(Application.StartupPath & "\Image\blablabla.jpg")
TextBox1.Focus()
iImage += 1
Case 2
PictureBox.Visible = True
PictureBox.Image = Image.FromFile(Application.StartupPath & "\Image\blablabla.jpg")
TextBox1.Focus()
iImage += 1
Case 3
PictureBox.Visible = False
Label1.Visible = True
iImage = 0
End Select
End Sub
Private Sub CheckImage()
Static Dim iImage As Integer
Select Case iImage
Case 0
If Not TextBox1.Text = "17" Then
MsgBox("Sorry ! You made a Mistake !", MsgBoxStyle.OKOnly, )
TextBox1.Text = ""
TextBox1.Focus()
Else
MsgBox("Congratulations ! It's Correct !", MsgBoxStyle.OKOnly, "PERFECT")
TextBox1.Text = ""
Button1.Visible = True
Button2.Visible = False
iImage += 1
End If
Case 1
If Not TextBox1.Text = "47" Then
MsgBox("Sorry ! You made a Mistake !", MsgBoxStyle.OKOnly, )
TextBox1.Text = ""
TextBox1.Focus()
Else
MsgBox("Congratulations ! It's Correct !", MsgBoxStyle.OKOnly, "PERFECT")
TextBox1.Text = ""
Button1.Visible = True
Button2.Visible = False
iImage += 1
End If
Case 2
If Not TextBox1.Text = "24" Then
MsgBox("Sorry ! you made a Mistake !", MsgBoxStyle.OKOnly, )
TextBox1.Text = ""
TextBox1.Focus()
Else
MsgBox("Congratulations! It's correct !", MsgBoxStyle.OKOnly, "PERFECT")
TextBox1.Text = ""
Button1.Visible = True
Button2.Visible = False
iImage += 1
End If
Case 3
PictureBox.Visible = False
Label1.Visible = True
iImage = 0
End Select
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CheckImage()
End Sub
End Class
I'm very pleased, thanks for your help!
Wkr,
sparrow1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|