By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

dim problem

P: 43
My problem is that I want to do this, but somehow its not working. (VB.NET)

I want to create objects:

dim a = 0
public sub Createo
a = a + 1
dim a as system.windows.forms.picturebox
a.image = textbox1.text
a.top = a + 5
a.left = a + 5
end sub

The problem is that a should be the count ( dim a = 0 )
dim a as system.windows.forms.picturebox

please help:
Jan 29 '08 #1
Share this Question
Share on Google+
4 Replies


jamesd0142
100+
P: 469
First of all:

dim a = 0 should be "dim a as integer = 0" right?

i cant work out why your defining a = 0 then
defining a as system.windows.forms.picturebox
Jan 29 '08 #2

P: 43
there is a button and every time the user clicks on it then one more picturebox appear.
Jan 29 '08 #3

jamesd0142
100+
P: 469
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim a As Integer = 0
  3.     Dim c As Integer = 0
  4.     Dim d As Integer = 0
  5.     Public Sub Createo()
  6.         c = c + 250
  7.         d = d + 250
  8.         a = a + 1
  9.         Dim b As System.Windows.Forms.PictureBox
  10.         b = New System.Windows.Forms.PictureBox()
  11.         b.Name = a
  12.         b.ImageLocation = TextBox1.Text
  13.         b.Location = New System.Drawing.Point(c, d)
  14.         b.Size = New System.Drawing.Size(300, 150)
  15.         Me.Controls.Add(b)
  16.     End Sub
  17.  
  18.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  19.         Createo()
  20.     End Sub
  21. End Class
  22.  
Jan 29 '08 #4

Expert 5K+
P: 8,434
My problem is that I want to do this, but somehow its not working. (VB.NET)...
I think the simple answer to this immediate problem is, don't use the same name for both variables.
Jan 30 '08 #5

Post your reply

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